I followed this answer and added a UIGestureRecognizer
to show or hide the Navbar and Toolbar. Strangely, the Navbar is not silding while hiding but it still slides when it reappears. the toolbar is animating all the time.
I changed the code to:
override var preferredStatusBarUpdateAnimation: UIStatusBarAnimation {
print("got called")
return UIStatusBarAnimation.slide
}
to see if it's being called when it hides and it is getting called. I also tried setting automaticallyAdjustsScrollViewInsets
to false as suggested by the comments from the same answer but still no luck.
I can't find any information about this issue anywhere.
EDIT: here's my complete code:
override func viewDidLoad(){
super.viewDidLoad()
self.automaticallyAdjustsScrollViewInsets = false
let gesture = UITapGestureRecognizer(target: self, action: #selector(toggle))
view.isUserInteractionEnabled = true
view.addGestureRecognizer(gesture)
}
func toggle() {
navigationController?.setNavigationBarHidden(navigationController?.isNavigationBarHidden == false, animated: true)
navigationController?.setToolbarHidden(navigationController?.isToolbarHidden == false, animated: true)
}
override var prefersStatusBarHidden: Bool {
print("got called 1")
return navigationController?.isNavigationBarHidden == true
}
override var preferredStatusBarUpdateAnimation: UIStatusBarAnimation {
print("got called 2")
return UIStatusBarAnimation.slide
}