Question

Apple say this:

barTintColor

This color is made translucent by default unless you set the translucent property to NO.

So why is my code producing an opaque navigation bar?

self.navigationController.navigationBar.barTintColor = [UIColor colorWithRed:0/255.0f     green:119/255.0f blue:255/255.0f alpha:1.0f];

I tried adding this just in case, but no luck.

self.navigationController.navigationBar.translucent = YES;

Thanks

Was it helpful?

Solution

Instead of this

self.navigationController.navigationBar.barTintColor = [UIColor colorWithRed:0/255.0f     green:119/255.0f blue:255/255.0f alpha:1.0f];

why don't you try setting the background color

self.navigationController.navigationBar.backgroundColor = [UIColor colorWithRed:0/255.0f     green:119/255.0f blue:255/255.0f alpha:1.0f];

The bar is translucent :)

As per your need. This will give a solid color to the navigation bar

NSArray *ver = [[UIDevice currentDevice].systemVersion componentsSeparatedByString:@"."];
if ([[ver objectAtIndex:0] intValue] >= 7) {
self.navigationController.navigationBar.barTintColor = [UIColor redColor];
self.navigationController.navigationBar.translucent = NO;
}else {
self.navigationController.navigationBar.tintColor = [UIColor redColor];
}

OTHER TIPS

Its much easier to use the "appearance" proxy in your appDelagate.m. In your didGinishLaunchingWithOptions method include:

[UINavigationBar appearance].translucent = NO;

Swift 4

  navigationController!.navigationBar.isTranslucent = false;
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top