tableView滑动删除、置顶等

iOS8自带方法自定义按钮背景。实现此代理即可。会覆盖系统自带的删除按钮。做记录。

#pragma mark 在滑动手势删除某一行的时候,显示出更多的按钮
- (NSArray *)tableView:(UITableView *)tableView editActionsForRowAtIndexPath:(NSIndexPath *)indexPath {

// 添加一个删除按钮
UITableViewRowAction *deleteRowAction = [UITableViewRowAction rowActionWithStyle:UITableViewRowActionStyleDestructive title:@"删除"handler:^(UITableViewRowAction *action, NSIndexPath *indexPath) {

NSLog(@"点击了删除");
self.tableView.editing =! self.tableView.editing;

}];

// 删除一个置顶按钮
UITableViewRowAction *topRowAction = [UITableViewRowAction rowActionWithStyle:UITableViewRowActionStyleDefault title:@"置顶" handler:^(UITableViewRowAction *action, NSIndexPath *indexPath) {

NSLog(@"点击了置顶");

}];

topRowAction.backgroundColor = [UIColor blueColor];

// 添加一个更多按钮
UITableViewRowAction *moreRowAction = [UITableViewRowAction rowActionWithStyle:UITableViewRowActionStyleNormal title:@"更多" handler:^(UITableViewRowAction *action, NSIndexPath *indexPath) {

NSLog(@"点击了更多");

}];

moreRowAction.backgroundEffect = [UIBlurEffect effectWithStyle:UIBlurEffectStyleLight];

// 将设置好的按钮放到数组中返回
return @[deleteRowAction, topRowAction, moreRowAction];

}
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • 发现 关注 消息 iOS 第三方库、插件、知名博客总结 作者大灰狼的小绵羊哥哥关注 2017.06.26 09:4...
    肇东周阅读 12,259评论 4 61
  • 获取团队信息(token) GET /v2/team/ 用户查看团队信息,该接口返回的是一个list,且不包含成员...
    soszrg阅读 627评论 0 0
  • 每一片银杏叶 都是一只黄蝴蝶 虽迟暮的季节 依旧被风儿携 那缕缕光线透过 晕染你不规则的轮廓 谁为影子泼墨 书写前...
    剪柳阅读 140评论 7 5
  • 你说:逗逼青年欢乐多,偶尔也想换一种情绪来体验体验?那给几首诗哭一哭吧! 趁天气干燥,趁阳光正盛,借几滴泪来纳凉纳...
    沐小雅不爱吃鱼阅读 1,061评论 5 11
  • 今天遛弯的时候老妈说起当年做小买卖的事,我才知道原来除了麻辣烫、铁板鱿鱼、油炸小点心之外,她还卖过梨和鱼肉。 老妈...
    一朵李小花阅读 888评论 0 2