I've been trying to change the color of the status bar in my Swift app, and I've identified four ways to do this in XCode. Yet, I have only been able to successfully use method 3:
1. Simulated Metrics (For Storyboard display only)
2. Change in General->Deployment Info->Status Bar Style
Make sure the following Info.list setting is set to "NO":
View controller-based status bar appearance : NO
Select either "Light" or "Default" in the dropdown box here:
General->Deployment Info->Status Bar Style
3. Set it Manually
Make sure the following Info.plist setting is set to "NO":
View controller-based status bar appearance : NO
Insert the following code (usually in didFinishLaunchingWithOptions):
UIApplication.sharedApplication().statusBarStyle = .LightContent
4. Override "preferredStatusBarStyle()"
Make sure the following Info.plist property exists and is set to "YES":
View controller-based status bar appearance : YES
Then add the following code to the UIViewController (or derived class) which is set for your ViewController in Storyboard:
override func preferredStatusBarStyle() -> UIStatusBarStyle {
return UIStatusBarStyle.LightContent
}
My current understanding
Simulated Metrics is just for display and provides no actual change during runtime. I believe setting manually and changing the setting in the general tab probably do the same thing under the hood, but I'm not sure. I imagine there is also a way to set this property directly for individual view controllers.
Question
For some reason, the only method which has actually worked for me is method 3, setting manually. None of the other methods provide any change. Personally, I would prefer to override in a derived class so I have a central place for my shared UIViewController styles.