Old McStopher
Old McStopher

Reputation: 6349

UIAppearance proxy caching appearance between compile times?

I'm using the the new UIAppearance API and have successfully set the tint color for all UINavigationBar and UIToolbar instances via my AppDelegate like so...

- (void)customizeAppearance
{
    UIColor *tint = [UIColor colorWithRed:212 green:63 blue:69 alpha:1.0];

    [[UINavigationBar appearance] setTintColor:tint];
    [[UIToolbar appearance] setTintColor:tint];
}

However, if I change the RGB value and re-build/run, the toolbars and nab bars all turn white, no matter what color I set it to!

It's as though the proxy is caching somewhere. When I delete the app, and then reinstall, the RGB values appear as they should, until I change them and rebuild again.

Has anyone else experienced this? Is there something I'm doing wrong?

UPDATE 1:

Now, I've noticed, it will arbitrarily switch to a white background between compile times without even changing the RGB. (NOTE: The RGB above should return a reddish tint.)

UPDATE 2:

My darling fiancée happened to be looking over my shoulder and noticed that in my test cases, the problem only seemed to occur when I had values in more than one RGB channel at a time.

For example:

UIColor *tint = [UIColor colorWithRed:212 green:0 blue:0 alpha:1.0];

worked, whereas

UIColor *tint = [UIColor colorWithRed:212 green:63 blue:69 alpha:1.0];

would not.

The solution?

Use colorWithHue:saturation:brightness:alpha: instead.

Upvotes: 0

Views: 203

Answers (1)

DJD
DJD

Reputation: 46

The problem is that [UIColor colorWithRed: green: blue: alpha:] takes a set of floats from 0.0f to 1.0f. You're passing in a set of integers.

Upvotes: 3

Related Questions