I have a custom one UITableViewCellwith UILabeland UIImageView. I want to change the background color and text color when the cell is highlighted. In my method CustomCell setHighlighted, I have the following code snippet:
-(void)setHighlighted:(BOOL)highlighted {
[super setHighlighted:highlighted];
if(self) {
if(highlighted) {
self.title.textColor = [UIColor whiteColor];
} else {
self.title.textColor = [UIColor blackColor];
}
UIView *bgColorView = [[UIView alloc] initWithFrame:self.frame];
bgColorView.backgroundColor = [UIColor blackColor];
[self setSelectedBackgroundView:bgColorView];
}
}
I already tried to put the code for textColorin tableView didSelectRowAtIndexPath, but this is not the effect that I want - I want the text color to change when the user touches the cell - not when touched. Any suggestions?
source
share