In a ViewController, which I presented modally, I did this:
override func prefersStatusBarHidden() -> Bool {
return true
}
This used
I'm using Xcode Version 9.2 / Swift 3.2 / iOS 11
I got this answer form BADCloud although I'm not sure why it didn't work for him.
Anyway it worked for me for a specific view controller.
The difference between this answer and the other answers on here is that in my info.plist when I initially had View controller-based status bar appearance - NO with the 2 statusBar methods below it didn't work but when I changed it to Yes is worked with both of them.
In the info.plist change:
View controller-based status bar appearance - YES
In the view controller you want it changed in add:
override func viewDidLoad() {
super.viewDidLoad()
// add this in ViewDidLoad
setNeedsStatusBarAppearanceUpdate()
}
// add this underneath ViewDidLoad
override var prefersStatusBarHidden: Bool {
return true
}