Changing the background color of the selected cell in a UITableView
The default value for selectedBackgroundView is nil for cells in plain-style tables (UITableViewStylePlain) and non-nil for section-group tables (UITableViewStyleGrouped).
If you’re using a plain-style table, you must alloc an init a new UIView with the desired background color, and then assign it to selectedBackgroundView.
Otherwise, if you just want a gray background, you should use:
|
1 |
cell.selectionStyle = UITableViewCellSelectionStyleGray; |





You are right, BUT there real matter is for CUSTOM cell view…
i know is old, but i found the solution for custom cells.
in your customcell class add the:
– (void)setSelected:(BOOL)selected animated:(BOOL)animated {
[super setSelected:selected animated:animated];
}
and the:
- (void)setHighlighted:(BOOL)highlighted animated:(BOOL)animated{
[super setHighlighted:highlighted animated:animated];
}
And you can do pretty much anything with the cells child objects with this, for example an image or a label or just add a view on the background and change its color with this.
Cheers