您的位置:首页 > 移动开发 > IOS开发

【iOS开发】添加系统自带的tableView左滑按钮

2016-08-13 00:03 537 查看
自定义cell左滑出现几个按钮的需求。

采用iOS系统自带的方法来实现。

具体代理方法

- (NSArray<UITableViewRowAction *> *)tableView:(UITableView *)tableView editActionsForRowAtIndexPath:(NSIndexPath *)indexPath;


完整代码如下

- (NSArray<UITableViewRowAction *> *)tableView:(UITableView *)tableView editActionsForRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewRowAction *deleteAction = [UITableViewRowAction rowActionWithStyle:UITableViewRowActionStyleNormal title:@"     删除" handler:^(UITableViewRowAction * _Nonnull action, NSIndexPath * _Nonnull indexPath) {

// 具体逻辑代码
}];
deleteAction.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"icon_boxDelete_normal"]];

UITableViewRowAction *editAction = [UITableViewRowAction rowActionWithStyle:UITableViewRowActionStyleNormal title:@"     编辑" handler:^(UITableViewRowAction * _Nonnull action, NSIndexPath * _Nonnull indexPath) {
}];
editAction.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"icon_boxEdit_normal"]];

return @[editAction, deleteAction];
}


效果图

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐