3
votes

I want to change the color on the navigation bar and the documentation states not to attempt to change the 'alpha' value. So, how can I set a color that is not the SDK defined values (e.g., [UIColor redColor], brownColor, etc.) if all the constructors provide an alpha value? I tried getting the current alpha value but that did not help. When I use a custom color, it causes the navigation bar to look like an x-ray (a scraggy, black-on-white).

[self.navigationController.navigationBar setTintColor: [UIColor brownColor]];
2

2 Answers

5
votes

I can be such an idiot ... for months now, I assumed the values ranged from 0..255 (i.e., HTML color values), but they are in the range [0.0 .. 1.0]. Now that I set my 0..255 value and normalize it to 0..1 it works as expected. I wrote a simple color-slider application and when I was debugging it, is when I realized my mistake.

0
votes

Try this:

When creating the UINavigationController initially

MyNavigationController *navigationController = [[MyNavigationController alloc] init];
[[navigationController navigationBar] setTintColor:[UIColor redColor]];