美文网首页iOS开发
IOS 自定义cell左滑删除按钮

IOS 自定义cell左滑删除按钮

作者: SivanJ | 来源:发表于2016-07-28 14:51 被阅读0次

                                                话不多说,先看效果!

    这样的功能实现起来其实很简单,实现一个代理方法就可以了!

    - (NSArray*)tableView:(UITableView*)tableView editActionsForRowAtIndexPath:(NSIndexPath*)indexPath

    {

    UITableViewRowAction*rowAction = [UITableViewRowActionrowActionWithStyle:UITableViewRowActionStyleDefaulttitle:@"删除"handler:^(UITableViewRowAction*_Nonnullaction,NSIndexPath*_NonnullindexPath) {

    NSLog(@"删除要实现的代码");

    }];

    UITableViewRowAction*rowAction1 = [UITableViewRowActionrowActionWithStyle:UITableViewRowActionStyleDefaulttitle:@"标为已读"handler:^(UITableViewRowAction*_Nonnullaction,NSIndexPath*_NonnullindexPath) {

    NSLog(@"标为已读要实现的代码");

    }];

    //自定义颜色

    rowAction.backgroundColor=RGB(231,96,35);

    rowAction1.backgroundColor=RGB(150,150,150);

    NSArray*arr =@[rowAction,rowAction1];

    return arr;

    }

    ps:因copy代码原因,小伙伴们自行把方法里缺少的空格加上!

    相关文章

      网友评论

        本文标题:IOS 自定义cell左滑删除按钮

        本文链接:https://www.haomeiwen.com/subject/fzyajttx.html