iOS UITableViewCell左滑/侧滑删除 仿微信
2019-08-01 本文已影响7人
yyggzc521
iOS11之后
- (nullable UISwipeActionsConfiguration *)tableView:(UITableView *)tableView trailingSwipeActionsConfigurationForRowAtIndexPath:(NSIndexPath *)indexPath API_AVAILABLE(ios(11.0))
iOS11之前
- (NSArray<UITableViewRowAction *> *)tableView:(UITableView *)tableView editActionsForRowAtIndexPath:(NSIndexPath *)indexPath
左滑删除网上参考资料很多,这里主要讲的是如何去除滑动手势满屏时第一个action变长效果?
当手指按着cell,一直往左滑动到屏幕最左边时,最右边的按钮(称为第一个按钮)会变长,并且送手后直接回调action的对应的block。要去除这个效果,需要设置UISwipeActionsConfiguration的属性performsFirstActionWithFullSwipe为NO即可
- (nullable UISwipeActionsConfiguration *)tableView:(UITableView *)tableView trailingSwipeActionsConfigurationForRowAtIndexPath:(NSIndexPath *)indexPath API_AVAILABLE(ios(11.0)){
UISwipeActionsConfiguration *config = [UISwipeActionsConfiguration configurationWithActions:@[ deleteAction,readStateAction,topAction ]];
config.performsFirstActionWithFullSwipe = NO;
return config;
}