For ViewController containment
suggest changeIf you are using view controller containment, a few other methods are worth looking at.
When you want a child view controller to control the status bar (for example, when the child sits at the top of the screen), return that child from childViewControllerForStatusBarStyle. The Swift below is Swift 2. Swift 3 imports these overrides as properties (childViewControllerForStatusBarStyle and preferredStatusBarStyle) and uses .default.
in Swift
class RootViewController: UIViewController {
private let messageBarViewController = MessageBarViewController()
override func childViewControllerForStatusBarStyle() -> UIViewController? {
return messageBarViewController
}
override func viewDidLoad() {
super.viewDidLoad()
//add child vc code here...
setNeedsStatusBarAppearanceUpdate()
}
}
class MessageBarViewController: UIViewController {
override func preferredStatusBarStyle() -> UIStatusBarStyle {
return .Default
}
}
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents