When I click on my UITableViewCell
, the background part (the areas that my background image doesn't cover) turns blue when I click on the cell. Also, all of the UILabel
s on the cell turn to white when it is clicked which is what I want.
However what I do not want is the blue background when I click it but if I do selectionstylenone
, then I lose the highlighted colours for the UILabel
s in the cell.
So is there any way to just get rid of the blue background when the cell is clicked but to keep the highlighted colors of the UILabel
s?
You can do this as follows. Set your table cell's selection style to UITableViewCellSelectionStyleNone
. This will remove the blue background highlighting. Then, to make the text label highlighting work the way you want, instead of using the default UITableViewCell class, create a subclass of UITableViewCell
and override the default implementation of setHighlighted:animated
with your own implementation that sets the label colors to however you want depending on the highlighted state.
- (void)setHighlighted:(BOOL)highlighted animated:(BOOL)animated { if (highlighted) { self.textLabel.textColor = [UIColor whiteColor]; } else { self.textLabel.textColor = [UIColor blackColor]; } }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With