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;
tentmaking
  • 2,076
  • 4
  • 30
  • 53

4 Answers4

56

Your code lists navigationController.navigationBar.translucent = YES;

Set it to NO.

Vadoff
  • 9,219
  • 6
  • 43
  • 39
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

Community
  • 1
  • 1
votelessbubble
  • 788
  • 6
  • 19
  • I will try to translate that into code. I am not using xib's. Thanks. – tentmaking Oct 04 '13 at 03:40
  • That didn't seem to work. When I set barStyle to UIBarStyleBlack, my UITableView items still show through the UINavigationBar. – tentmaking Oct 04 '13 at 03:44
  • Then try removing translucency – votelessbubble Oct 04 '13 at 03: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! – votelessbubble Oct 04 '13 at 03:53
7

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

Nick Yap
  • 887
  • 1
  • 10
  • 13
1
self.navigationController.navigationBar.isTranslucent = false