How to turn the Navigation Bar in iOS 6 opaque when compiling with Xcode 5

Xcode 5 is nice… but it has habits that drive me up the wall. For example, no matter which Base SDK you compile with, your Navigation Bars will always look translucent – no matter how hard you try to avoid this in the Storyboard, and no matter which iOS Version you deploy to.

Would have never happened under Xcode 4. But I suppose we must go with the times.

All we can do is to turn it opaque in code – and if we’re not using black, at least give iOS 7 a tint of your selected colour at the same time. This method will take a UINavigationController and change its colour:

Note that on iOS 7 your navigation bars are always translucent, I haven’t found a way to change this. All you can do is “tint” those. The above code will however bring opaqueness back into your apps when running on iOS 6.

About Jay Versluis

Jay is a medical miracle known as Super Survivor. He runs two YouTube channels, five websites and several podcast feeds. To see what else he's up to, and to support him on his mission to make the world a better place, check out his Patreon Campaign.

2 thoughts on “How to turn the Navigation Bar in iOS 6 opaque when compiling with Xcode 5

  1. Minor snag:
    If you run the above code on on iOS 6 device, and you’re compiling with the iOS 6 SDK, the compiler will throw an error saying that UINavigationController does not respond to tintColor.

    A better way to determine iOS version is this:

  2. This works fine on both iOS 6.x and iOS 7.1:

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.