For ViewController containment

suggest change

If 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 
    }
}

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents