11

This is in an app I'm converting from iOS 6. Initially the ViewController was showing up under iOS 7 with the content of the main view underneath the navigation bar.

In the UI builder view, I turned off "Under Top Bars" and "Under Bottom Bars" in the "Extend Edges" section, to solve that issue. This worked, however, now on this screen the navigation bar appears to be translucent (comes across as grey in the screenshot below).

I've tried explicitly setting "Top Bar" to "Opaque Navigation Bar" under "Simulated Metrics," but this has no effect.

I've tried setting:

self.navigationController.navigationBar.translucent = NO;

in my ViewController's init code, but this also has no effect.

What am I missing?

UPDATE: If I set self.navigationController.navigationBar.translucent = NO; in my first ViewController in the stack, it works. However, prior to the ViewController in question, I do want translucent navbar. It's only when I get to a view several layers deep that I want to have a non-translucent bar (this view has no scrollable data, so it doesn't make sense to have it translucent).

Here's a screenshot of what I'm seeing in the nav bar:

Attempt to make bar white opaque have failed thus far in iOS 7...

Mason G. Zhwiti
  • 6,444
  • 11
  • 61
  • 97
  • http://stackoverflow.com/questions/18929864/how-do-i-change-the-navigation-bar-color-in-ios-7/18929980#18929980 – Rajneesh071 Sep 25 '13 at 05:04

4 Answers4

20

The issue was that I was calling

self.navigationController.navigationBar.translucent = NO;

after my view appeared. I moved that code into my viewWillAppear method, and now it appears correctly:

Correct

Mason G. Zhwiti
  • 6,444
  • 11
  • 61
  • 97
5

You can try below code...

self.navigationController.navigationBar.barTintColor = [UIColor redColor];
self.navigationController.navigationBar.translucent = NO;  

And Add this code in View viewDidLayoutSubviews function...

Hindu
  • 2,894
  • 23
  • 41
5

You can set it across the board with an app using this:

UINavigationBar.appearance().navigationBarAppearace.translucent = false

I tend to do it in my AppDelegate class when the app initially loads up.

1

all you need to do for iOS6 is to set the controller's fullscreenlayout to NO and then PUSH it to your NavigationController

[controller setWantsFullScreenLayout:NO];
Saurabh Passolia
  • 8,099
  • 1
  • 26
  • 41