demo效果图如下:
核心代码
- (void)configSwipeButtons {
if (@available(iOS 11.0, *)) {
//iOS 11系统以后 查找删除按钮
for (UIView *subview in self.tableView.subviews) {
if ([subview isKindOfClass:NSClassFromString(@"UISwipeActionPullView")] &&
[subview.subviews count]) {
UIButton *deleteButton = subview.subviews[0];
[self configDeleteButton:deleteButton];
}
}
}
else {
//iOS 11系统以前 查找删除按钮
ViewCell *tableCell = [self.tableView cellForRowAtIndexPath:self.editingIndexPath];
for (UIView *subview in tableCell.subviews) {
if ([subview isKindOfClass:NSClassFromString(@"UITableViewCellDeleteConfirmationView")] && [subview.subviews count]) {
UIButton *deleteButton = subview.subviews[0];
[self configDeleteButton:deleteButton];
}
}
}
}