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 an开发者_JAVA技巧y help.
Set the labels' highlightColor
property to white.
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]];
}
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]];
}
}
精彩评论