玩转tableViewCell 侧滑按钮UITableViewCellDeleteConfirmationView

大家都知道只需要实现- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {}就能实现侧滑删除功能, 但是只能实现一个按钮, 并且样式还很丑^_^, 然后趁着周末
摘要由CSDN通过智能技术生成

大家都知道只需要实现

- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {}

就能实现侧滑删除功能, 但是只能实现一个按钮, 并且样式还很丑^_^, 然后趁着周末休息时间研究了一下tableViewCell的一些功能(没做优化, 只是研究了一下属性)

这里写图片描述

其实, 从iOS8开始, 苹果就新增了一个API

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

可以看到, 返回的是一个UITableViewRowAction数组, 每一个UITableViewRowAction都代表着一个action,
比如

- (NSArray<UITableViewRowAction *> *)tableView:(UITableView *)tableView editActionsForRowAtIndexPath:(NSIndexPath *)indexPath {
    /* UITableViewRowAction属性
     + (instancetype)rowActionWithStyle:(UITableViewRowActionStyle)style title:(nullable NSString *)title handler:(void (^)(UITableViewRowAction *action, NSIndexPath *indexPath))handler;

     //按钮样式
     @property (nonatomic, readonly) UITableViewRowActionStyle style;
     //按钮标题
     @property (nonatomic, copy, nullable) NSString *title;
     //按钮背景色
     @property (nonatomic, copy, nullable) UIColor *backgroundColor;
     //背景毛玻璃效果    
     @property (nonatomic, copy, nullable) UIVisualEffect* backgroundEffect;
*/
    
  • 2
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值