I doing a project where i need to use highlighted table view color not default.
Asked
Active
Viewed 2,280 times
2 Answers
9
Of course you can.
There are two methods to achieve this:
- Use
UITableViewCell
'sselectedBackgroundView
andselectedTextColor
properties - Subclass
UITableViewCell
and implement thedrawInRect
andsetSelected:animated:
methods
The latter option gives you more flexibility and much better performance, but it might be slightly harder if you haven't used CoreGraphics before.
UPDATE In response to the OP's comment:
Here's how you can use the selectedBackgroundView
property:
UIView *bgView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, 60)];
[bgView setBackgroundColor:[UIColor redColor]];
[cell setSelectedBackgroundView:bgView];
[bgView release];
I haven't tried this myself, but it should work.

Can Berk Güder
- 109,922
- 25
- 130
- 137
-
Can you elaborate on the first method? I tried `cell.selectedBackgroundView.backgroundColor = [UIColor redColor]` but it didn't seem to change anything. – Daniel Dickison Apr 09 '09 at 17:49