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

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!

Answers


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]];

If you want to keep using the appearance proxy, you will have to create a custom table view cell and a new label.

  1. In the storyboard editor you set the style property of your UITableCell to "custom".
  2. Drag two label to the table view cell and configure it like you want it.
  3. Create a new class that inherits from UITableViewCell and make IBOutlets for every label.
  4. In the storyboard editor you set the class of the table view cell to the table view cell class you just created. Connect the outlets to the labels. Actually this is enough, because you can configure the appearance of the cells in the storyboard as well. If you want to configure the label through code you have to execute the following steps as well.
  5. Create a new class that inherits from UILabel and leave it as is.
  6. Go back to the storyboard editor and select the detailtextlabel and change the class to the label class you just create.

If you want more information on how to create your own table view cells see Table View Programming Guide for IOS


Need Your Help

HttpAddUrl permissions

c++ windows security networking winhttp

I'm trying to run a custom WinHTTP based web-server on Windows Server 2008 machine.

.htaccess redirect to mobile version issues

apache .htaccess redirect mobile

I have tried to solve this problem looking about the internet before asking but cannot solve it this is as far as I have got.