cell_滑动

/*
//iOS_11.0
-(UISwipeActionsConfiguration *)tableView:(UITableView *)tableView trailingSwipeActionsConfigurationForRowAtIndexPath:(NSIndexPath *)indexPath{
    
    __weak typeof(self) weakSelf = self;
    
    __block ZLJInventDataItem *inventModel = self.inventArray[indexPath.row];
    UIContextualAction    *other;
    //禁用状态
    if (inventModel.useState == 1) {
        //需要使用启用功能
        other = [UIContextualAction contextualActionWithStyle:UIContextualActionStyleDestructive
                                                        title:@"启用"
                                                      handler:^(UIContextualAction * _Nonnull action, __kindof UIView * _Nonnull sourceView, void (^ _Nonnull completionHandler)(BOOL)) {
                                                          [weakSelf updateShareReocrdWithRecordId:inventModel.kId
                                                                                             type:@"0"
                                                                                        startTime:inventModel.startTime 
                                                                                        doSuccess:^(BOOL success) {
                                                                                            
                                                                                            if (success) {
                                                                                                inventModel.useState = 0;
                                                                                                [weakSelf.recordTableView reloadRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationNone];
                                                                                            }
                                                                                        }];
                                                          completionHandler(NO);
                                                      }];
        
    }else if(inventModel.useState == 0){//启用状态
        //需要使用禁用功能
        other = [UIContextualAction contextualActionWithStyle:UIContextualActionStyleDestructive
                                                        title:@"禁用"
                                                      handler:^(UIContextualAction * _Nonnull action, __kindof UIView * _Nonnull sourceView, void (^ _Nonnull completionHandler)(BOOL)) {
                                                          [weakSelf updateShareReocrdWithRecordId:inventModel.kId
                                                                                             type:@"1"
                                                                                        startTime:inventModel.startTime 
                                                                                        doSuccess:^(BOOL success) {
                                                                                            
                                                                                            if (success) {
                                                                                                inventModel.useState = 1;
                                                                                                [weakSelf.recordTableView reloadRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationNone];
                                                                                            }
                                                                                        }];
                                                          completionHandler(NO);
                                                      }];
    }
    UIContextualAction    *delete = [UIContextualAction contextualActionWithStyle:UIContextualActionStyleDestructive
                                                                            title:@"删除"
                                                                          handler:^(UIContextualAction * _Nonnull action, __kindof UIView * _Nonnull sourceView, void (^ _Nonnull completionHandler)(BOOL)) {
                                                                              [weakSelf updateShareReocrdWithRecordId:inventModel.kId
                                                                                                                 type:@"2"
                                                                                                            startTime:inventModel.startTime 
                                                                                                            doSuccess:^(BOOL success) {
                                                                                                                if (success) {
                                                                                                                    [weakSelf.inventArray removeObjectAtIndex:indexPath.row];
                                                                                                                    [weakSelf.recordTableView reloadData];
                                                                                                                }
                                                                                                            }];
                                                                              completionHandler(NO);
                                                                          }];
    
    other.backgroundColor = [UIColor lightGrayColor];
    UISwipeActionsConfiguration *actions = [UISwipeActionsConfiguration configurationWithActions:@[delete,other]];
    actions.performsFirstActionWithFullSwipe = NO;
    return actions;
}
*/
//iOS_8.0
-(NSArray<UITableViewRowAction *> *)tableView:(UITableView *)tableView editActionsForRowAtIndexPath:(NSIndexPath *)indexPath{
    
    
    UITableViewRowAction *rowAction = [UITableViewRowAction rowActionWithStyle:UITableViewRowActionStyleNormal 
                                                                         title:@"删除" 
                                                                       handler:^(UITableViewRowAction * _Nonnull action, NSIndexPath * _Nonnull indexPath) {
        
    
                                                                       }];
    rowAction.backgroundColor = [UIColor redColor];
    UITableViewRowAction *rowaction = [UITableViewRowAction rowActionWithStyle:UITableViewRowActionStyleNormal 
                                                                         title:@"禁用" 
                                                                       handler:^(UITableViewRowAction * _Nonnull action, NSIndexPath * _Nonnull indexPath) {
        
                                                                       }];
    rowaction.backgroundColor = [UIColor grayColor];
    NSArray *arr = @[rowAction,rowaction];
    return arr;
}
原文地址:https://www.cnblogs.com/tom2015010203/p/9927958.html