IOS 7 changes the font color of the UITableViewCell to blue, as in the Settings app

I have a question. So I got UITableviewin a grouped style, and there is one cell that I want to use as a button. My problem is that the font color of this cell is black by default. I want to have the same blue color as the cells used as buttons in the settings application (for example, in settings / safari, the delete history cell is used as a button, and this light iOS 7 has a blue color as the font color). I would love it if someone could help me. Lots of love, Timm

+4
source share
2 answers

If you are using a storyboard or xib, and you have a prototype cell, go to it and select the shortcut. Then you can set the color of the text.

If you want to do this programmatically, add the following to your method tableView:cellForRowAtIndexPath::

cell.textLabel.textColor = [UIColor blueColor];

blueColor not exactly the same as the blue used by buttons in iOS 7, but you can manually select a color that closely approximates it if you want.

EDIT:

This will give you the exact color you want:

UIButton *button = [UIButton buttonWithType:UIButtonTypeSystem];
cell.textLabel.textColor = [button titleColorForState:UIControlStateNormal];

Gets the color from UIButton.

+11
source

You can use this line of code in your method cellForRowAtIndexPathto adjust the color UITableViewCell:

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {

    // (cell creation)...

    // set to the color that Apple uses
    cell.textLabel.textColor = [UIColor colorWithRed:0.204 green:0.459 blue:1.000 alpha:1.0];
    return cell;
} 

Let me know if this helped you.

+3
source

All Articles