iPhone iOS UILabel how to customize text color for UITableView detail text labels only?

Alex Stone picture Alex Stone · Jun 13, 2012 · Viewed 18k times · Source

I'm working on an interface prototype and am using a storyboard to do so. Part of the prototype involves setting the detail UILabel for UITableView cells to a certain color. I would like to avoid having to manually recolor every label within a storyboard.

I found that I can use:

[[UILabel appearanceWhenContainedIn:[UITableViewCell class], nil] 
 setTextColor:[UIColor cyanColor]];

To change the appearance of labels within tableview cells. Is there a way to further refine this code to only apply to detail tableview labels? Currently it changes both textLabel and detailTextLabel of UITableViewCell.

Thank you!

Answer

Omar Abdelhafith picture Omar Abdelhafith · Jun 13, 2012

You could trick around this by subclassing the cells in the detail view, then use

[[UILabel appearanceWhenContainedIn:[YOUR_UITableViewCell class], nil] 
 setTextColor:[UIColor other_colr]];