Search code examples
iphoneiosuinavigationbartintcolor

Navigation bar type: the code is?


I have a Navigation Bar created via code. When I change it's tintColor the bar is bad. Hoverer the color is plain and not iOS style. Can I change this? Thanks

enter image description here

UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:frontViewController];
   navigationController.navigationBar.tintColor = [UIColor colorWithRed:0 green:166 blue:208 alpha:1];

Solution

  • This is because the method call to UIColor you are making expects float values between 0.0 and 1.0, whereas you are passing in straight RBG values as ints:

    This will work:

    myNavigationBar.tintColor = [UIColor colorWithRed:((0 * 1.0) / 255) green:((166 * 1.0) / 255) blue:((208 * 1.0) / 255) alpha:1.0];