UITableView 左右滑动时,出现删除按钮的动画。

我想大家搞IOS的都很容易调出UITableView左右滑动时出现的哪个删除按钮吧。大家可能也注意到了,当滑动时按钮是从右向左动画展开的,但再次点击CELL时,按钮直接就隐藏掉了。注意,这个不是点击edit时出来的哪个删除。上次找了些资料关于点击CELL后,这个删除动画再次从左向右的动画隐藏。就像IPHONE通话记录中的左右滑的删除按钮效果一样。


实现:

在继承tableViewcell的类中进行以下代码处理:

- (void)layoutSubviews {

    [super layoutSubviews];


    //动画隐藏系统删除按钮

    [UIView animateWithDuration:.3 animations:^{

    

    for (UIView *subview in self.subviews)

    {

        if ([NSStringFromClass([subview class]) isEqualToString:@"UITableViewCellDeleteConfirmationControl"])

        {

            if (deleteVisable)

            {

                //隐藏动画

                CGRect newFrame = subview.frame;

                newFrame.origin.x = 252;

                newFrame.size.width = 0;

                subview.frame = newFrame;

                deleteVisable = !deleteVisable;

                

                //如果删除按钮隐藏的时候,要重新注册手执,否则左边出不来。

                //[self registerGesture];

            }

            else

            {   //展示动画

                CGRect newFrame = subview.frame;

                newFrame.origin.x = 222;

                newFrame.size.width = 60;

                subview.frame = newFrame;

                deleteVisable = !deleteVisable;

            }

        }

        /*

        else if ([NSStringFromClass([subview class]) isEqualToString:@"UITableViewCellEditControl"]) {

            CGRect newFrame = subview.frame;

            newFrame.origin.x = 100;

            subview.frame = newFrame;

        }

        else if ([NSStringFromClass([subview class]) isEqualToString:@"UITableViewCellReorderControl"]) {

            CGRect newFrame = subview.frame;

            newFrame.origin.x = 200;

            subview.frame = newFrame;

        }

         */

    }

    

    } completion:^(BOOL finished){

    }];

}


以上代码在IOS5。0以上测试通过,大家如果还有更好的实现方式,请留言。谢谢。


  • 0
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 5
    评论
评论 5
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

边缘998

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值