Reputation: 3052
My view controller hierarchy is SWRevealViewController
-> UINavigationViewController
-> MyController1
. MyController1
presents MyController2
using self.present
. MyController2
is not within UINavigationViewController
and presentation is modal (device is iPhone). In viewWillAppear
of MyController2
I call self.setNeedsStatusBarAppearanceUpdate()
, but preferredStatusBarStyle
is never called by the system and status bar appearance remains same (as it was for MyViewController1
). Am I missing something here?
EDIT
info.plist
has View controller-based status bar appearance set to YES
Upvotes: 3
Views: 5276
Reputation: 803
This is what worked for me in my VC...
self.modalPresentationCapturesStatusBarAppearance = true
Upvotes: 6
Reputation: 665
Our issue was a container VC.
So had to tell it to allow the contained (visible) VC to call the shots:
final class ContainerVC: UIViewController {
final var centerVC: UIViewController? // set to an OtherVC elsewhere
override var childViewControllerForStatusBarHidden: UIViewController? {
return centerVC
}
override var childViewControllerForStatusBarStyle: UIViewController? {
return centerVC
}
}
final class OtherVC: UIViewController {
override var prefersStatusBarHidden: Bool {
return true
}
override var preferredStatusBarStyle: UIStatusBarStyle {
return .lightContent
}
override var preferredStatusBarUpdateAnimation: UIStatusBarAnimation {
return .slide
}
}
Upvotes: 4
Reputation: 2149
in your info.plist
View controller-based status bar appearance make it YES
Upvotes: 4