0

I am using the below code to make all my buttons in an application the same color. However the accessory icon in the UITTableView row also has it. Is there a way to ignore it in the table view?

[[UIButton appearance] setBackgroundColor:[UIColor purpleColor]];
Matthias Bauch
  • 89,811
  • 20
  • 225
  • 247
Mike Flynn
  • 22,342
  • 54
  • 182
  • 341

2 Answers2

1

A UIView conforms to the UIAppearanceContainer protocol.

So you should use appearanceWhenContainedIn: to distinct buttons depending on where they are contained in.

[[UIButton appearance] setBackgroundColor:[UIColor purpleColor]];    
[[UIButton appearanceWhenContainedIn:[UITableView class], nil] setBackgroundColor:nil];

It would be best to use the UITableViewCell subclass instead of the table view.

Léo Natan
  • 56,823
  • 9
  • 150
  • 195
0

You can use the

[[UIButton appearanceWhenContainedIn: [UITableView class]] setBackgroundColor:[UIColor differentColor]];
Raymond Brion
  • 332
  • 1
  • 10