Reputation: 392
In my vertical scrollView
(having 2 containerView
s of the size of device screen) I want to hide a View
(added to my window) when user scrolls down, but don't want to hide it when the user scrolls up, i.e., when scrollView
's contentOffset.y
is currently 0 and on again trying to scroll it remains to be 0 only.
if self.scrollView.contentOffset.y == 0
{
myView.isHidden = true
}
else if self.scrollView.contentOffset.y > 0 {
myView.isHidden = true
}
Upvotes: 2
Views: 819
Reputation: 2010
set scrollViewDelegate to VC, then:
func scrollViewDidScroll(scrollView: UIScrollView) {
myView.isHidden = scrollView.panGestureRecognizer.translationInView(scrollView.superview).y < 0
}
Upvotes: 2