iOS开发

IOS 自定义cell左滑删除按钮

2016-07-28  本文已影响0人  SivanJ

                                            话不多说,先看效果!

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

- (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代码原因,小伙伴们自行把方法里缺少的空格加上!

上一篇下一篇

猜你喜欢

热点阅读