John D John D - 1 year ago 112
Swift Question

Hide status bar whenever nav bar is hidden - SWIFT iOS8

How can I had the status bar whenever the view is scrolling with:

self.navigationController?.hidesBarsOnSwipe = true

or if not hide the status bar, how can I keep my status bar from overlaying my view?

ty awesome stackoverflow community

Answer Source

Sorry if this answer is a little late, but here is one way to do it.

Use the prefersStatusBarHidden() method within your view controller.

override func prefersStatusBarHidden() -> Bool {
    if self.navigationController?.navigationBarHidden == true {
        return true
    } else {
        return false

Basically says that when the Nav bar is hidden, then the status bar is too and vice versa.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download