I’m trying to set the color of the selected row in a UITableView, using this code:
- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath {
cell.backgroundColor = [UIColor redColor];
}
}
The problem is, it’s setting the color on all the rows. Furthermore, when I do select a specific row, it highlights that row in blue. How do I get it to just highlight the selected row, in red?
The easiest way to me is to subclass
UITableViewCelland overwrite thesetSelected:method (leave everything else the same if you need to)some sample code from an old project: