I doing a project where i need to use highlighted table view color not default.
views:
774answers:
2
+4
A:
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
2009-04-09 08:31:35
Can you elaborate on the first method? I tried `cell.selectedBackgroundView.backgroundColor = [UIColor redColor]` but it didn't seem to change anything.
Daniel Dickison
2009-04-09 17:49:49
I updated my answer.
Can Berk Güder
2009-04-09 18:13:02
A:
i clean up a demo refer to http://code.google.com/p/table-group-cell-background-color-demo/, may be you could have a look at it and get some help
jiansihun
2010-10-13 08:55:48