-
(nullable UISwipeActionsConfiguration *)tableView:(UITableView *)tableView trailingSwipeActionsConfigurationForRowAtIndexPath:(NSIndexPath *)indexPath {
UIContextualAction *deleteAction = [UIContextualAction
contextualActionWithStyle:UIContextualActionStyleDestructive
title:@"删除"
handler:^(UIContextualAction * _Nonnull action,
__kindof UIView * _Nonnull sourceView,
void (^ _Nonnull completionHandler)(BOOL))
{
[self.titles removeObjectAtIndex:indexPath.row];[self.tableView deleteRowsAtIndexPaths: [NSArray arrayWithObjects:indexPath, nil] withRowAnimation:UITableViewRowAnimationAutomatic]; completionHandler(true);
}];
// 设置按钮图片
[deleteAction setImage:[UIImage imageNamed:@"Star"]];
NSArray *actions = [[NSArray alloc] initWithObjects:deleteAction, nil];
return [UISwipeActionsConfiguration configurationWithActions:actions];
}