2018-05-08 [OC] UITableViewCellReorderControl 改变默认图片

方法一:改在Controller里面

参考:ios - Reorder tableview cell with a custom button - postion and image

- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath
{
    if (self.tableView.editing)
    {
        for (UIView * view in cell.subviews)
        {
            if ([NSStringFromClass([view class]) rangeOfString: @"UITableViewCellReorderControl"].location != NSNotFound)
            {
                for (UIView * subview in view.subviews) {
                    if ([subview isKindOfClass: [UIImageView class]])
                    {
                        ((UIImageView *)subview).image = [UIImage imageNamed: @"accessory_next"];
                    }
                }
            }
        }
    }
}

方法二:改在UITableViewCell里面

参考:# Change default icon for moving cells in UITableView

- (void) setEditing:(BOOL)editing animated:(BOOL)animated
{
    [super setEditing: editing animated: YES];

    if (editing) {

        for (UIView * view in self.subviews) {
            if ([NSStringFromClass([view class]) rangeOfString: @"Reorder"].location != NSNotFound) {
                for (UIView * subview in view.subviews) {
                    if ([subview isKindOfClass: [UIImageView class]]) {
                        ((UIImageView *)subview).image = [UIImage imageNamed: @"yourimage.png"];
                    }
                }
            }
        }
    }   
}

你可能感兴趣的:(2018-05-08 [OC] UITableViewCellReorderControl 改变默认图片)