Ben Sullivan Ben Sullivan - 1 month ago 4
Swift Question

Enabling lightContent status bar style in a VIPER project

In previous versions of Swift, to change the status bar style I would use 'preferredStatusBarStyle' and return .lightContent.

This method is now unavailable, I have tried every solution on SO such as:

self.navigationController?.navigationBar.barStyle =
self.navigationController?.isNavigationBarHidden = true

However, these techniques do not work. Can someone please shed some light on this. Currently in my plist, I have 'statusBarStyle' set to 'UIStatusBarStyleLightContent'.

You're welcome to download my project here:


In iOS 10, preferredStatusBarStyle is a property, not a method. So instead of overriding it with a func declaration, you override the getter with a var declaration.

override var preferredStatusBarStyle: UIStatusBarStyle {
   return .lightContent