? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? 話不多說,先看效果!

這樣的功能實(shí)現(xiàn)起來其實(shí)很簡單,實(shí)現(xiàn)一個(gè)代理方法就可以了!
- (NSArray*)tableView:(UITableView*)tableView editActionsForRowAtIndexPath:(NSIndexPath*)indexPath
{
UITableViewRowAction*rowAction = [UITableViewRowActionrowActionWithStyle:UITableViewRowActionStyleDefaulttitle:@"刪除"handler:^(UITableViewRowAction*_Nonnullaction,NSIndexPath*_NonnullindexPath) {
NSLog(@"刪除要實(shí)現(xiàn)的代碼");
}];
UITableViewRowAction*rowAction1 = [UITableViewRowActionrowActionWithStyle:UITableViewRowActionStyleDefaulttitle:@"標(biāo)為已讀"handler:^(UITableViewRowAction*_Nonnullaction,NSIndexPath*_NonnullindexPath) {
NSLog(@"標(biāo)為已讀要實(shí)現(xiàn)的代碼");
}];
//自定義顏色
rowAction.backgroundColor=RGB(231,96,35);
rowAction1.backgroundColor=RGB(150,150,150);
NSArray*arr =@[rowAction,rowAction1];
return arr;
}
ps:因copy代碼原因,小伙伴們自行把方法里缺少的空格加上!