Joe Joe - 2 months ago 30
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

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

override func viewDidLoad() {
super.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 8.my navigation and toolbar went black for some reason ?

Thanks in Advance...

Answer

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
Comments