I have a UITableview
in grouped style and there is one cell that I want to use like a button. My problem is, the font color of this cell is by default black. I want to have the same blue as font color as the cells used as buttons in the settings app (e.g. in settings/safari the delete history cell is used as a button and has this light iOS 7 styled blue as font color). I would love it if anybody could help me.
Much love, Timm
If you're using a storyboard or xib and you have a prototype cell, go in to it and select the label. Then you can set the color of the text.
If you want to do it programmatically, add the following to your tableView:cellForRowAtIndexPath:
method:
cell.textLabel.textColor = [UIColor blueColor];
blueColor
isn't exactly the same as the blue used by buttons in iOS 7, but you could manually pick a color that closely approximates it if you wanted instead.
EDIT:
This will give you the exact color you want:
UIButton *button = [UIButton buttonWithType:UIButtonTypeSystem];
cell.textLabel.textColor = [button titleColorForState:UIControlStateNormal];
It's getting the color from a UIButton.
You can use this line of code in your cellForRowAtIndexPath
method to set up UITableViewCell
's font color:
- (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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With