title: Scroll up and down to hide and show view with delegate functions of UIscrollview
body: <p>I have implemented the <code>scrollViewWillEndDragging</code> to hide the view when users scroll down and once scroll up the view will show immediately. But problem is by using the code below, when user scroll up, the view appear but will hide again when user fingers leave the screen. Is there any better solution for creating the action to show and hide the view I need? Thanks all</p>
  
  <pre><code>func scrollViewWillEndDragging(_ scrollView: UIScrollView, withVelocity velocity: CGPoint, targetContentOffset: UnsafeMutablePointer&lt;CGPoint&gt;) {
          if scrollView == searchCollection{
              if targetContentOffset.pointee.y &lt; scrollView.contentOffset.y {
                  // it's going up
                  headerViewHeightConstraint.constant = 110
                  UIView.animate(withDuration: 0.5, delay: 0, options: [.allowUserInteraction], animations: {
                      self.view.layoutIfNeeded()
                  }, completion: nil)
              } else {
                  // it's going down
                  headerViewHeightConstraint.constant = 0
                  UIView.animate(withDuration: 0.5, delay: 0, options: [.allowUserInteraction], animations: {
                      self.view.layoutIfNeeded()
                  }, completion: nil)
              }
  
          }
        }
  </code></pre>