0

我有一个 uitableview,我在其中添加了两个自定义按钮(接受/拒绝),它们也设置了样式,并且还检测了从哪个行按钮被按下。现在我希望它们在用户滑动时默认隐藏,然后它们出现像动画一样的删除按钮。

4

1 回答 1

2

这正是您需要的:

UISwipeGestureRecognizer *deleteRecognizer = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(gestureToShowDeleteButton:)];
            deleteRecognizer.direction = UISwipeGestureRecognizerDirectionRight;
            [deleteRecognizer setNumberOfTouchesRequired:1];
            [cell addGestureRecognizer:deleteRecognizer];
            [deleteRecognizer release];

现在在您的视图控制器中添加一个方法“gestureToShowDeleteButton”,并在此方法中使用动画显示删除按钮...

这将进入gestureToShowDeleteButton方法......

[UIView animateWithDuration:0.2 delay: 0.0 options: UIViewAnimationOptionCurveEaseIn animations:^{ 
    [btnDeleteButton setFrame:CGRectMake(160, 10, 128, 55)]; 
    } 
    completion:^(BOOL finished){ }
    ];

使用框架 (288,10,0,55) 初始化按钮,前提是按钮的尺寸为 128x55....

希望能帮助到你... ;)

于 2012-07-17T07:04:44.860 回答