- (NSArray<UITableViewRowAction *> *)tableView:(UITableView *)tableView editActionsForRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewRowAction *deleteRowAction = [UITableViewRowActionrowActionWithStyle:UITableViewRowActionStyleDestructivetitle:@"删除"handler:^(UITableViewRowAction *_Nonnull action, NSIndexPath *_Nonnull indexPath) {
[self.deleteSourceremoveObjectAtIndex:indexPath.row];//根据某行删除某个cell
[self.tableViewdeleteRowsAtIndexPaths:@[indexPath]withRowAnimation:UITableViewRowAnimationAutomatic];
}];
UITableViewRowAction *topRowAction = [UITableViewRowActionrowActionWithStyle:UITableViewRowActionStyleDefaulttitle:@"置顶"handler:^(UITableViewRowAction *_Nonnull action, NSIndexPath *_Nonnull indexPath) {
[self.deleteSourceexchangeObjectAtIndex:indexPath.rowwithObjectAtIndex:0];//改变某个cell所在的位置
NSIndexPath *firstIndexPath = [NSIndexPathindexPathForRow:0inSection:indexPath.section];//将选中的cell 放至第一位
[tableView moveRowAtIndexPath:indexPathtoIndexPath:firstIndexPath];
}];
topRowAction.backgroundColor = [UIColorblueColor];
UITableViewRowAction *moreRowAction = [UITableViewRowActionrowActionWithStyle:UITableViewRowActionStyleNormaltitle:@"更多"handler:^(UITableViewRowAction *_Nonnull action, NSIndexPath *_Nonnull indexPath) {
[self.tableViewreloadRowsAtIndexPaths:@[indexPath]withRowAnimation:UITableViewRowAnimationMiddle];
}];
return@[deleteRowAction,topRowAction,moreRowAction];
}