views:

168

answers:

3

Hello, I am using a custom cell with multiple labels contained in it. I would like to change the text color of all labels to white, when the cell is selected. How would do this?

Appreciate any help.

+4  A: 

In the implementation of the custom cell class overwrite the following method

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
     [super setSelected:(BOOL)selected animated:(BOOL)animated];
     [someLabel setTextColor:[UIColor whiteColor]];
}
Felix
This simply sets the label textcolor to white even at the start of the app.
Prasanna
+2  A: 

Set the labels' highlightColor property to white.

Ole Begemann
A: 

either set the highlighted/selected color(code or ib) or do what the above poster suggested except you need to put it inside an if statement since that code sets the text even if the cells get sent a deselected value

eg..

  • (void)setSelected:(BOOL)selected animated:(BOOL)animated { [super setSelected:(BOOL)selected animated:(BOOL)animated]; if (selected) { [someLabel setTextColor:[UIColor whiteColor]]; } }
drunknbass