Since you are using a custom table cell, you can implement code to set label colors by implementing the setSelected and setHighlighted methods in your custom UITableViewCell. This will capture all state changes from the selection, although there are some complicated cases, for example, when setHighlighting is called with NO, when you select and drag outside the cell after it has already been selected. Here is the approach I used that I believe sets the color correctly in all cases.
- (void)updateCellDisplay { if (self.selected || self.highlighted) { self.nameLabel.textColor = [UIColor lightGrayColor]; self.colorLabel.textColor = [UIColor lightGrayColor]; } else { self.nameLabel.textColor = [UIColor blackColor]; self.colorLabel.textColor = [UIColor blackColor]; } } - (void)setHighlighted:(BOOL)highlighted animated:(BOOL)animated { [super setHighlighted:highlighted animated:animated]; [self updateCellDisplay]; } - (void) setSelected:(BOOL)selected animated:(BOOL)animated { [super setSelected:selected animated:animated]; [self updateCellDisplay]; }
source share