Swift 3 - how to hide status bar when using full screen
I am developing a quick application and I cannot find how to hide the status bar when I use over a full screen view in my modal level.
However, I put this line of code in my Modal View Controller:
override var prefersStatusBarHidden: Bool {
return true
}
And it works if I create a segue that is not modal, or if I create a segue that is modal but not with Over Full Screen view.
I searched the internet for how to fix this and I found people who had the same problem but there was no solution.
Also, I cannot change the color of my status bar when I use the Full Screen option. I do not understand why? I think it is related.
Thank you for your help!
source to share
We can override preferredStatusBarStyle
from a separate view controller as you did right.
Along with this, insert a new key named "View Controller Based Dashboard Status" and set the value to NO info.plist
.
With "View Status Bar in Control Panel" disabled, you can style the status bar using the following code.
[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent]; //objective-c
Hence, it should decide "I cannot change the color of my status bar when using the Full Screen option.
source to share
To hide the status bar when executing a fullscreen modal value, you need to set this in viewDidLoad:
override func viewDidLoad() {
super.viewDidLoad()
modalPresentationCapturesStatusBarAppearance = true
}
Then follow the standard method to hide the status bar:
override var prefersStatusBarHidden: Bool {
return true
}
source to share