how do I properly change my status bar style in swift 2/ iOS 9? how do I properly change my status bar style in swift 2/ iOS 9? ios ios

how do I properly change my status bar style in swift 2/ iOS 9?


Apple have added the capability to change the status bar style in the deployment info. Simply choose 'Light'.ScreenShot of Xcode

Also set View controller-based status bar appearance key to NO in the Info.plist

info plist


I always did this way.

class ViewController: UIViewController {    override func viewDidLoad() {        super.viewDidLoad()        // Do any additional setup after loading the view, typically from a nib.    }    //Changing Status Bar    override func preferredStatusBarStyle() -> UIStatusBarStyle {        //LightContent        return UIStatusBarStyle.LightContent        //Default        //return UIStatusBarStyle.Default    }}

It works in any swift 2.x version. This requires that you set View controller-based status bar appearance in your Info.plist file to YES.


Swift 3 just add View controller-based status bar appearance with value NO to info.plistand then add to ViewControllerwhere you want:

UIApplication.shared.statusBarStyle = UIStatusBarStyle.lightContent