Reputation: 6396
When my app launches, I'm setting [[UIButton appearance] setBackgroundColor:[UIColor someColor]]
in order to modify the appearance of the buttons throughout my app. However, this appears to have given me the unwanted side-effect of also changing the background color of the disclosure indicators in my table views. It seems to only set the un-selected state, so if I press-and-hold on the cell, the background color goes clear.
Setting the background color on the cell's accessoryView
does not work as I'm not using my own accessory view, just setting the accessoryType
to use the disclosure indicator.
I've seen some other questions about trying to change the accessory's background to match the cell's background color, which seem to involve using a custom accessory UIImageView
or setting the background color on the contentView
instead of the cell. The latter doesn't apply because that's not the issue I'm having, and the former seems like overkill to "un-override" the UIButton appearance
that I'm setting.
Is there a way to remove the custom appearance
setting for the disclosure indicators?
Edit: not sure if it matters, but I'm using custom UITableViewCell
s.
Upvotes: 1
Views: 720
Reputation: 90117
use appearanceWhenContainedIn:
to "reset" the appearance when the UIButton is contained in a UITableViewCell
e.g.:
[[UIButton appearance] setBackgroundColor:[UIColor redColor]];
[[UIButton appearanceWhenContainedIn:[UITableViewCell class], nil] setBackgroundColor:[UIColor clearColor]];
Upvotes: 1