Joe Joe - 1 year ago 122
Swift Question

NavigationBar barStyle no changing in Xcode 8

I have a navigationBar and toolbar running in my project in the same view controller. I was using the

to customise the look of navigation & toolbar in Swift 2 as follows:

override func viewDidLoad() {
// Do any additional setup after loading the view, typically from a nib.

// Navigation style and Apperance
// ------------------------------

navigationController!.navigationBar.barStyle = UIBarStyle.blackOpaque
navigationController!.navigationBar.tintColor = UIColor.white
navigationController!.navigationBar.isTranslucent = true

navigationController!.toolbar.barStyle = UIBarStyle.blackOpaque
navigationController!.toolbar.tintColor = UIColor.white
navigationController!.toolbar.isTranslucent = true

Everything worked and the bars look transparent.But, After I updated my Xcode 7 to Xcode navigation and toolbar went black for some reason ?

Thanks in Advance...

Answer Source

Here is my snippet which should work with XCode 8 (& Swift 3):

navController.navigationBar.setBackgroundImage(UIImage(), for: UIBarMetrics.default)
navController.navigationBar.shadowImage = UIImage()
navController.navigationBar.isTranslucent = true
navController.navigationBar.tintColor = UIColor.white
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download