Reputation: 1683
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!
Upvotes: 4
Views: 3941
Reputation: 1683
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
Upvotes: 2
Reputation: 4379
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.
Upvotes: 5
Reputation: 4337
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.
Upvotes: 3