iOS tableviewcell 左滑自定义view
今天接到一个特殊的需求
我手机iOS14的系统 所以只考虑了iOS14 的解决办法 不适用于所有iOS系统
- (void)tableView:(UITableView *)tableView willBeginEditingRowAtIndexPath:(NSIndexPath *)indexPath {
// 在 iOS11 以下系统,因为方法线程问题,需要放到主线程执行, 不然没有效果
dispatch_async(dispatch_get_main_queue(), ^{
[self setupSlideBtnWithEditingIndexPath:indexPath];
});
}
//MARK: 设置左滑按钮的样式
- (void)setupSlideBtnWithEditingIndexPath:(NSIndexPath *)editingIndexPath {
// 判断系统是否是 iOS13 及以上版本
if (@available(iOS 13.0, *)) {
for (UIView *subView in self.tableView.subviews) {
if ([subView isKindOfClass:NSClassFromString(@"_UITableViewCellSwipeContainerView")] && [subView