UINavigationBar BarTintColor not working with RGB Values

ios, uinavigationbar

Solution

You have to divide your RGB values by `255.0` because `UIColor` expects values in `0.0-1.0` range:

NSUInteger r = 127, g = 127, b = 127;
UIColor *color = [UIColor colorWithRed:r/255.0 green:g/255.0 blue:b/255.0 alpha:1.0];

Problem

I spent about an hour trying to figure out why my BarTintColor wasn't changing in a UINavigation bar. I guess that you cannot use RGB to set the BarTintColor? Is there a workaround for this? I want to be able to control the color. UPDATE: OK kambla helped me a lot. I put the following in my app delegate at the tail end of of "applicationdidFinishLaunchingWithOptions" ``` NSUInteger r = 228, g = 228, b = 228; UIColor *color = [UIColor colorWithRed:r / 255.0 green:g / 255.0 blue:b / 255.0 alpha:0]; [[UINavigationBar appearance] setBarTintColor:color]; return YES; ``` I confirmed that the code is executing. But the tint color on my navigation bars do not change?

Original source