0

here's my tableview cell editing mode image

I want to change the check image background view turn to clear color, but I don't know how to do, could anyone help me solve this problem?

here's my code

for (UIControl *control in self.subviews){

    if ([control isMemberOfClass:NSClassFromString(@"UITableViewCellEditControl")]){

        for (UIView *v in control.subviews) {

            if ([v isKindOfClass: [UIImageView class]]) {
            UIImageView *img=(UIImageView *)v;
                if (self.selected) {
                    img.image=[UIImage imageNamed:@"check"];
                }else{
                    img.image=[UIImage imageNamed:@"uncheck"];
                }
            }
        }
    }
}
  • Try [this](https://stackoverflow.com/questions/281515/how-to-customize-the-background-color-of-a-uitableviewcell) – Ptit Xav Feb 24 '22 at 12:13
  • Does this answer your question? [How to customize the background color of a UITableViewCell?](https://stackoverflow.com/questions/281515/how-to-customize-the-background-color-of-a-uitableviewcell) – Ptit Xav Feb 24 '22 at 12:13

1 Answers1

0

You would normally do that kind of thing on the cell level rather. You can test for editing mode by making a function like configureCell and update the image accordingly. Something like this...

if (editing){
    [self.checkImage setBackgroundColor:[UIColor clearColor]];
    }
else {
    [self.checkImage setBackgroundColor:[UIColor colorWithRed:.8 green:.8 blue:1 alpha:1]];
    }

then call that function from your cellForRowAt indexPath or from willBeginEditingRowAtIndexPath or one of the many others available for UITableViews.

Happy Coding :)

AMAN77
  • 6,218
  • 9
  • 45
  • 60
  • I tried this method, but it only change the image background color, but what I want to change is the color of the imageview's Superview , but I don't know how to get the superview and change the superview's frame. – kency CHANG Feb 25 '22 at 01:21
  • Have you tried [self.superview setBackgroundColor:[UIColor clearColor]]; – AMAN77 Feb 25 '22 at 09:28