Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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!

like image 255
aaisataev Avatar asked Oct 20 '25 04:10

aaisataev


2 Answers

if you are want to hide and show just navigation bar on scrollView.

you can override viewDidAppear. & use hidesBarsOnSwipe property of navigation controller.

override func viewDidAppear(animated: Bool) {

    super.viewDidAppear(animated)
    
    navigationController?.hidesBarsOnSwipe = true

}

Hope This Answer helps you.

like image 74
Ketan P Avatar answered Oct 22 '25 17:10

Ketan P


Try make a variable shouldHideStatusBar

And override this func:

override func prefersStatusBarHidden() -> Bool {
    return shouldHideStatusBar
}

when scroll put it:

shouldHideStatusBar = true/false
self.setNeedsStatusBarAppearanceUpdate()

Hope this help.

like image 33
vien vu Avatar answered Oct 22 '25 19:10

vien vu