Custom table view cell selection font color

ios, ios5, uitableview

Solution

Set the label's highlightedTextColor and this will all be done for you automatically. You should not have to do anything special in setSelected at all.

e.g.

_subjectLabel.highlightedTextColor = [UIColor whiteColor];

Problem

I have a custom `UITableViewCell`. It has 3 custom labels inside it with custom text. When i tap on the cell, i want the textColor of all those labels to go white. just like Email app `UITableViewCell` behavior. For that, I wrote this in the custom cell class. ``` - (void)setSelected:(BOOL)selected animated:(BOOL)animated { [super setSelected:selected animated:animated]; // Configure the view for the selected state if (self.selected) { _subjectLabel.textColor = [UIColor whiteColor]; _messageLabel.textColor = [UIColor whiteColor]; _usernameLabel.textColor = [UIColor whiteColor]; }else { _subjectLabel.textColor = [UIColor blackColor]; _messageLabel.textColor = [UIColor grayColor]; _usernameLabel.textColor = [UIColor blackColor]; } } ``` I was able to get it. But its not as smooth as it is in the Email app. The color changes only after a small delay. Which method of `UITableViewCell` should I override to put this code in. I know about the below options, but they don't give the behavior onto custom labels in the custom cell. ``` typedef enum { UITableViewCellSelectionStyleNone, UITableViewCellSelectionStyleBlue, UITableViewCellSelectionStyleGray } UITableViewCellSelectionStyle; ```

Original source