0

I am posting this after following this thread:

How to hide the navigation bar and toolbar as scroll down? Swift (like myBridge app)

I have the following Nav bar:

enter image description here

And I want it to disappear when I scroll down in the UICollectionView and appear when I scroll up.

I have added the code from the posted thread above:

func scrollViewWillEndDragging(_ scrollView: UIScrollView, withVelocity velocity: CGPoint, targetContentOffset: UnsafeMutablePointer<CGPoint>) {

    if(velocity.y>0) {
        UIView.animate(withDuration: 2.5, delay: 0, options: UIViewAnimationOptions(), animations: { 
            self.navigationController?.setNavigationBarHidden(true, animated: true) 
            self.navigationController?.setToolbarHidden(true, animated: true)
            print("Hide")
        }, completion: nil)

    } else {
        UIView.animate(withDuration: 2.5, delay: 0, options: UIViewAnimationOptions(), animations: { 
            self.navigationController?.setNavigationBarHidden(false, animated: true)
            self.navigationController?.setToolbarHidden(false, animated: true)
            print("Unhide")
        }, completion: nil)    
      }
   }

But when I scroll down it won't disappear (Neither will the TabBar).

Can someone point me to what I might be doing wrong? Does it have anything to do with the fact I am scrolling the UICollectionView and perhaps not the View?

Ofri
  • 289
  • 5
  • 17

0 Answers0