- (
NSArray
<
UITableViewRowAction
*> *)tableView:(
UITableView
*)tableView editActionsForRowAtIndexPath:(
NSIndexPath
*)indexPath
{
UITableViewRowAction *deleteRowAction = [ UITableViewRowAction rowActionWithStyle : UITableViewRowActionStyleDestructive title : @" 删除 " handler :^( UITableViewRowAction * _Nonnull action, NSIndexPath * _Nonnull indexPath) {
[ self . deleteData removeObjectAtIndex :indexPath. row ];
[ self . tableView deleteRowsAtIndexPaths : @[ indexPath ] withRowAnimation : UITableViewRowAnimationAutomatic ];
}];
UITableViewRowAction *topRowAction = [ UITableViewRowAction rowActionWithStyle : UITableViewRowActionStyleDefault title : @" 置顶 " handler :^( UITableViewRowAction * _Nonnull action, NSIndexPath * _Nonnull indexPath) {
[ self . deleteData exchangeObjectAtIndex :indexPath. row withObjectAtIndex : 0 ];
NSIndexPath *firstIndexPath = [ NSIndexPath indexPathForRow : 0 inSection :indexPath. section ];
[tableView moveRowAtIndexPath :indexPath toIndexPath :firstIndexPath];
}];
topRowAction. backgroundColor = [ UIColor blueColor ];
UITableViewRowAction *moreRowAction = [ UITableViewRowAction rowActionWithStyle : UITableViewRowActionStyleNormal title : @" 更多 " handler :^( UITableViewRowAction * _Nonnull action, NSIndexPath * _Nonnull indexPath) {
[ self . tableView reloadRowsAtIndexPaths : @[ indexPath ] withRowAnimation : UITableViewRowAnimationMiddle ];
}];
// moreRowAction.backgroundEffect = [UIBlurEffect effectWithStyle:UIBlurEffectStyleDark];
return @[ deleteRowAction,topRowAction,moreRowAction ] ;
{
UITableViewRowAction *deleteRowAction = [ UITableViewRowAction rowActionWithStyle : UITableViewRowActionStyleDestructive title : @" 删除 " handler :^( UITableViewRowAction * _Nonnull action, NSIndexPath * _Nonnull indexPath) {
[ self . deleteData removeObjectAtIndex :indexPath. row ];
[ self . tableView deleteRowsAtIndexPaths : @[ indexPath ] withRowAnimation : UITableViewRowAnimationAutomatic ];
}];
UITableViewRowAction *topRowAction = [ UITableViewRowAction rowActionWithStyle : UITableViewRowActionStyleDefault title : @" 置顶 " handler :^( UITableViewRowAction * _Nonnull action, NSIndexPath * _Nonnull indexPath) {
[ self . deleteData exchangeObjectAtIndex :indexPath. row withObjectAtIndex : 0 ];
NSIndexPath *firstIndexPath = [ NSIndexPath indexPathForRow : 0 inSection :indexPath. section ];
[tableView moveRowAtIndexPath :indexPath toIndexPath :firstIndexPath];
}];
topRowAction. backgroundColor = [ UIColor blueColor ];
UITableViewRowAction *moreRowAction = [ UITableViewRowAction rowActionWithStyle : UITableViewRowActionStyleNormal title : @" 更多 " handler :^( UITableViewRowAction * _Nonnull action, NSIndexPath * _Nonnull indexPath) {
[ self . tableView reloadRowsAtIndexPaths : @[ indexPath ] withRowAnimation : UITableViewRowAnimationMiddle ];
}];
// moreRowAction.backgroundEffect = [UIBlurEffect effectWithStyle:UIBlurEffectStyleDark];
return @[ deleteRowAction,topRowAction,moreRowAction ] ;
}