I have implemented scrollViewDidScroll so that a header view (pagerView) will collapse as the user scrolls the scrollView. It works perfectly if the content of the scrollView is long enough so that it scrolls off the top of the screen. But, if there is less content, the scrollView will stick, i.e. stop scrolling once it reaches its bottom, and not allow scrolling back down. Any help would be fantastic.
let pagerViewMaxHeight = 350
let pagerViewMinHeight = 44 + statusBarHeight
func scrollViewDidScroll(_ scrollView: UIScrollView) {
let y = scrollView.contentOffset.y
let newPagerViewHeight = pagerViewHeight.constant - y
if newPagerViewHeight > pagerViewMaxHeight {
pagerViewHeight.constant = pagerViewMaxHeight
} else if newPagerViewHeight < pagerViewMinHeight {
pagerViewHeight.constant = pagerViewMinHeight
} else {
pagerViewHeight.constant = newPagerViewHeight
scrollView.contentOffset.y = 0
}
}