The correct way to do is set the selectedBackgroundView and backgroundView to the cell.
- (UITableViewCell*)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"CELL"];
if(!cell){
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"CELL"];
UIView * selectedBackgroundView = [[UIView alloc] initWithFrame:CGRectZero];
selectedBackgroundView.backgrounColor = [UIColor colorWithRed:1.0 green:0.0 blue:0.0 alpha:1.0];
cell.selectedBackgroundView = selectedBackgroundView
}
return cell;
}
This way you dont have to set the background color when the selection is done and change the color back when deselected.
If you would like to change the text properties based on selection, sub class UITableViewCell and override setSelected:animated method.
- (void)setSelected:(BOOL)selected animated:(BOOL)animated{
[super setSelected:selected animated:animated];
self.textLabel.titleColor.textColor = selected ? selectedColor : notSelectedColor;
}