Joe Joe - 11 months ago 85
Swift Question

NavigationBar barStyle not 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