Reputation: 321
I am making an app which allows users to change the theme, eg. changing the background colour. Assuming I have a button, when click, toggles the change in background colour.
Eg. in code:
@IBAction func floodLightAction(sender: AnyObject) {
previousFloodlightOption = loadFloodlightOption()
if previousFloodlightOption {
print("OFF")
saveFloodlightOption(false)
// configure theme for themeViewController:
UIApplication.sharedApplication().statusBarStyle = .Default
setNeedsStatusBarAppearanceUpdate()
configureFloodlight(false)
} else {
print("ONN")
saveFloodlightOption(true)
// configure theme for themeViewController:
UIApplication.sharedApplication().statusBarStyle = .LightContent
setNeedsStatusBarAppearanceUpdate()
configureFloodlight(true)
}
However, setNeedsStatusBarAppearanceUpdate() does not seem to update the status bar style when the button is pressed. I have a few custom functions which are explained below.
My custom save func:
saveFloodlightOption(bool: Bool)
My theme configuration func:
configureFloodLight(bool: Bool)
I hope I gave enough information, thanks!
Upvotes: 0
Views: 75
Reputation: 2994
Have you set View Controller Based Status bar appearance
to false
in your info.plist?
View Controller Based status bar appearance
Upvotes: 1