Search code examples
iosswiftnavbarstatusbar

Show status bar when hide navigation bar


I hide navbar when user scrolls the table up.

func scrollViewWillBeginDragging(scrollView: UIScrollView) {
    if self.navigationController?.navigationBarHidden == false {
        self.navigationController?.setNavigationBarHidden(true, animated: true)
    }
}

But this method also hides the status bar.

Can't keep my status bar. These methods don't work:

UIApplication.sharedApplication().setStatusBarHidden(false, withAnimation: .None)
prefersStatusBarHidden()

Please, help!


Solution

  • Was my mistake. Status bar wasn't hidden, it was just white like a table view background. Just set this when nav bar is hidden:

    UIApplication.shared.statusBarStyle = .default