John D John D - 3 months ago 22
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

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.