Hide status bar with hidden navigation bar - SWIFT iOS8

How can I have a status bar whenever a view scrolls with:

    self.navigationController?.hidesBarsOnSwipe = true

or if you don't hide the status bar, how can I save my status bar from overlaying my view?

ty awesome community stackoverflow

+4
source share
2 answers

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

Use the prefersStatusBarHidden () method in your view controller.

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

It is basically said that when the Nav panel is hidden, then the status bar is also vice versa.

+5
source

A Swift 3 elegant solution:

open override var prefersStatusBarHidden: Bool {
    return navigationController?.isNavigationBarHidden ?? false
}
+6
source

Source: https://habr.com/ru/post/1568682/


All Articles