meaning-matters
meaning-matters

Reputation: 22946

Change overall tintColor and font-size of UITableViewCellStyleValue2 textLabel in iOS 7

I have a Skinning module where I define my app wide tintColor for general use in the app:

+ (UIColor*)tintColor
{
    return [UIColor colorWithRed:0.26f green:0.41f blue:1.00f alpha:1.00f];
}

and I use this to set the app's overall tint color:

[UIApplication sharedApplication].keyWindow.tintColor = [Skinning tintColor];

But UITableViewCellStyleValue2's `textLabel color remained the same. So I have to do:

cell.textLabel.textColor = [Skinning tintColor];

for each and every cell.

I suppose there's no overall way to set this once, or is there?

I have the same issue for the font-size. By default it's 15 points, but in iOS Setting etc. they used the 18 points system-font.

Upvotes: 0

Views: 518

Answers (1)

Andrea Sprega
Andrea Sprega

Reputation: 2271

I've had the same problem before, and I think the best solution is to write a custom subclass of UITableViewCell and set up the various textLabels color in an overridden cell constructor (e.g. – initWithStyle:reuseIdentifier:). In the same spot you can also set the font sizes.

Another approach (which doesn't seem to fit well in your case) would be to use the UIAppearance proxy for labels contained in table view cells, but then the appearance would be set for every cell class, every label (main and detail), every style:

[[UILabel appearanceWhenContainedIn:[UITableViewCell class], nil] setTextColor:[Skinning tintColor]];

There seems to be no way for doing it only for certain table view cell styles.

Upvotes: 2

Related Questions