29

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;
2
  • Post the code of how you are setting translucent. Commented Oct 4, 2013 at 5:46
  • 4
    Try to put self.navigationController.navigationBar.translucent = NO; in your testViewController. Commented Oct 4, 2013 at 15:55

4 Answers 4

56

Your code lists navigationController.navigationBar.translucent = YES;

Set it to NO.

9

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

4
  • I will try to translate that into code. I am not using xib's. Thanks.
    – tentmaking
    Commented Oct 4, 2013 at 3:40
  • That didn't seem to work. When I set barStyle to UIBarStyleBlack, my UITableView items still show through the UINavigationBar.
    – tentmaking
    Commented Oct 4, 2013 at 3:44
  • Then try removing translucency Commented Oct 4, 2013 at 3:47
  • Ok, what ive got from the details you have provided. You have a UINavBar and UITableView in one view controller, fine? Ive had this kind of problem before so i had used a container view for my UITable view. I put the container view on the view controller where navbar is there and the table view in the Container's View controller! Hope this works! Commented Oct 4, 2013 at 3:53
7

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

1
self.navigationController.navigationBar.isTranslucent = false

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.