Change the color of UILabel inside table cell when cell is tapped

ios, objective-c, uilabel, uitableview

Solution

There is a delegate `didSelectRowAtIndexPath` method called when cell is being selected

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath*)indexPath{
   UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath]; //Get your cell for selected row       
   cell.leftMenuItemLabel.textColor = [UIColor redColor];//Configure whatever color you want
}

Problem

I have a cell with an UIImage and UILabel inside it: I have this code for setting up its content, pretty standard stuff: ``` - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *itemCellID = @"menuItem"; NSString *currentMenuLabel = [self.menuItemStructure objectAtIndex:[indexPath row]]; NSString *currentMenuIcon = [self.menuItemIcon objectAtIndex:[indexPath row]]; MTNLeftMenuItemCell *cell = [self.tableView dequeueReusableCellWithIdentifier:itemCellID]; [cell.leftMenuItemLabel setText:currentMenuLabel]; UIImage *icon = [UIImage imageNamed:currentMenuIcon]; [cell.leftMenuItemIcon setImage:icon]; cell.selectionStyle = UITableViewCellSelectionStyleNone; return cell; } ``` Now what I want to do is change this `UILabel's` text color when the cell is tapped, sort of like `.cell .label:hover { ... }` in css. This seems rather obvious in retrospect, but the `UILabel` being the subview of the cell is what confuses me. How can I do this?

Original source