PDA

View Full Version : UITableViewCell custom labels -- color when selected




xinevil
Apr 19, 2009, 02:06 PM
Hi,

I have a custom UITableViewCell with two UILabels in it. When I select the tableCell, I want the UILabels textColor to be white, until the selection is done (with [tableView deselectRowAtIndexPath:indexPath animated:YES]).
All of Apples custom cells do the same (look at settings app, contacts app, etc.).
I had a kind-of-solution: use -(void)setSelected:(BOOL)selected animated:(BOOL)animated;
But the problem is the label gets white too late (the cell will become black as soon as you touch it, but the labels will become white as soon as you let go the touch).
Also: where do I make the labels textColor black again, so that it animates from white to black precisely as the cell animates from blue to white?



Niiro13
Apr 19, 2009, 05:28 PM
Are you talking about the label in a cell turning to white when the background is blue?

If that's the case then you'd use:

[label setHighlightedTextColor:[UIColor whiteColor]];

xinevil
Apr 20, 2009, 12:14 AM
Are you talking about the label in a cell turning to white when the background is blue?

If that's the case then you'd use:

[label setHighlightedTextColor:[UIColor whiteColor]];

Nice thanks :D.
Sometimes it can be sooooo easy :P .