How to get an opaque UINavigationBar on iOS 7

25,058

Solution 1

Your code lists navigationController.navigationBar.translucent = YES;

Set it to NO.

Solution 2

To make it totally opaque u can just change the style of the navigation bar from the property section itself!

Just set the style as Black!

This is how it looks like when u make it black

Solution 3

To make all of your navigation bars opaque, you could just add UINavigationBar.appearance().translucent = false to application:didFinishLaunchingWithOptions:

Solution 4

self.navigationController.navigationBar.isTranslucent = false
Share:
25,058
tentmaking
Author by

tentmaking

Updated on May 18, 2020

Comments

  • tentmaking
    tentmaking about 4 years

    Is there any way to make the UINavigationBar, targeted for iOS 7, a solid color with no translucency? I have tried setting the backgroundColor, the barTintColor, opaque, transparent/translucent, etc... and nothing works.

    Anyone know how to do this?

    Here are some chunks of code I have been using. Notice the properties I have set on the navigationBar. None of them, in any order or combination have worked.

    @property (strong, nonatomic) UITabBarController *tabBarController;
    
    testViewController = [[TestViewController alloc] init];
    anotherViewController = [[AnotherViewController alloc] init];
    navigationController = [[UINavigationController alloc]
                                initWithRootViewController:testViewController];
    
    navigationController.navigationBar.barTintColor = [UIColor darkGrayColor;
    navigationController.navigationBar.barStyle = UIBarStyleBlack;
    navigationController.navigationBar.translucent = YES;
    navigationController.navigationBar.opaque = YES;
    
    NSArray *tabBarViewControllers = [NSArray arrayWithObjects:
                                          navigationController,
                                          anotherViewController, nil];
    self.tabBarController.viewControllers = tabBarViewControllers;