做一个自定义的左滑删除按钮 带图片的 找了好久的资料就这个可以的记录一下
加一下这个代理就可以了
- (UISwipeActionsConfiguration *)tableView:(UITableView *)tableView trailingSwipeActionsConfigurationForRowAtIndexPath:(NSIndexPath *)indexPath API_AVAILABLE(ios(11.0)){
//删除
if (@available(iOS 11.0, *)) {
UIContextualAction *delete = [UIContextualAction contextualActionWithStyle:UIContextualActionStyleDestructive title:@"" handler:^(UIContextualAction * _Nonnull action, __kindof UIView * _Nonnull sourceView, void (^ _Nonnull completionHandler)(BOOL)) {
[self.mutArr removeObjectAtIndex:indexPath.row];
[self.tableView deleteRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationFade];
completionHandler (YES);
}];
delete.image = [UIImage imageNamed:@"money_pop_icon"];//这里还可以设置图片
delete.backgroundColor = HEX(0xF3F3F3);
UISwipeActionsConfiguration *config = [UISwipeActionsConfiguration configurationWithActions:@[delete]];
return config;
} else {
return nil;
// Fallback on earlier versions
}
}