iOS随笔

iOS tableView自定义删除按钮

2017-08-02  本文已影响15人  TIGER_XXXX

实现下面的代理方法

// 自定义左滑显示编辑按钮
- (NSArray<UITableViewRowAction*>*)tableView:(UITableView *)tableView editActionsForRowAtIndexPath:(NSIndexPath *)indexPath {
    UITableViewRowAction *rowAction = [UITableViewRowAction rowActionWithStyle:UITableViewRowActionStyleDefault 
                                                                         title:@"删除" 
                                                                       handler:^(UITableViewRowAction * _Nonnull action, NSIndexPath * _Nonnull indexPath) 
    {
        NSLog(@"删除");
    }];
    rowAction.backgroundColor = [UIColor yellowColor];
    NSArray *arr = @[rowAction];
    return arr;
}
上一篇 下一篇

猜你喜欢

热点阅读