更改uitableview单元格删除按钮背景颜色

时间:2014-07-17 07:48:29

标签: ios iphone objective-c uitableview

我已经看过如何处理link

我关注并在我的视图控制器中实现它具有tableview和其他子视图。 Tableview单元格由自定义单元格实现。

问题是,我从未见过这个" UITableViewCellDeleteConfirmationView"更改UITableView单元格删除按钮颜色的颜色。我在iOS7上写作。那么,它已经不同了吗?或者我做错了什么?

 -(void)viewWillLayoutSubviews
{
    [super viewWillLayoutSubviews];

    NSArray *subviews = [self.view subviews];

    // Return if there are no subviews
    if ([subviews count] == 0) return;

    for (UIView *subview1 in subviews)
    {
        NSLog(@"subview1 > %@",NSStringFromClass([subview1 class]));


        for(UIView *subview2 in subview1.subviews)
        {
            NSLog(@"subview2 > %@",NSStringFromClass([subview2 class]));


            for(UIView *subview3 in subview2.subviews)
            {
                NSLog(@"subview3 > %@",NSStringFromClass([subview3 class]));


                for(UIView *subview4 in subview3.subviews)
                {
                    NSLog(@"subview4 > %@",NSStringFromClass([subview4 class]));

                    for(UIView *subview5 in subview4.subviews)
                    {
                        NSLog(@"subview5 > %@",NSStringFromClass([subview5 class]));

                        for(UIView *subview6 in subview5.subviews)
                        {
                            NSLog(@"subview6 > %@",NSStringFromClass([subview6 class]));

                        }

                    }

                }


            }


            //
            //            if ([NSStringFromClass([subview2 class])     isEqualToString:@"UITableViewCellDeleteConfirmationView"])
            //            {
            //                //your color
            //                ((UIView*)[subview2.subviews firstObject]).backgroundColor=[UIColor blueColor];
            //                
            //                
            //            }
        }


    }

}

1 个答案:

答案 0 :(得分:2)

尝试自定义单元格类。

- (void)layoutSubviews
{
    [super layoutSubviews];
    for (UIView *subview in self.subviews) {

        for(UIView *subview2 in subview.subviews){
            if ([NSStringFromClass([subview2 class]) isEqualToString:@"UITableViewCellDeleteConfirmationView"]) {

                ((UIView*)[subview2.subviews firstObject]).backgroundColor=[UIColor yellowColor];
            }
        }
    }    
}