John D
John D

Reputation: 1545

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

Upvotes: 5

Views: 2663

Answers (2)

luizv
luizv

Reputation: 638

A Swift 3 elegant solution:

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

Upvotes: 6

Demonic Penguin
Demonic Penguin

Reputation: 249

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.

Upvotes: 5

Related Questions