更改UITableViewCellEditingStyleDelete的图像

时间:2014-04-07 15:08:57

标签: ios objective-c uitableview

有人知道如何更改UITable单元格减号按钮的背景图片,

enter image description here

我需要将此按钮enter image description here更改为enter image description here

因为如果您在iOS6和iOS7之间进行更改,则此按钮会更改。

1 个答案:

答案 0 :(得分:1)

希望这会对你有所帮助

- (void)willTransitionToState:(UITableViewCellStateMask)state
    {
        [super willTransitionToState:state];
        if ((state & UITableViewCellStateShowingDeleteConfirmationMask) == UITableViewCellStateShowingDeleteConfirmationMask)
        {
            for (UIView *subview in self.subviews)
            {
                if ([NSStringFromClass([subview class]) isEqualToString:@"UITableViewCellDeleteConfirmationControl"])
                {
                    UIImageView *deleteBtn = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, 64, 33)];
                    [deleteBtn setImage:[UIImage imageNamed:@"deleteNewImg.png"]];
                    [[subview.subviews objectAtIndex:0] addSubview:deleteBtn];
                }
            }
        }
    }