UIScrollView should only scroll down
1 answer
Decision
Subclass UIScrollView and override the methods to limit horizontal scrolling and scroll down only:
class DownwardsOnlyScrollView: UIScrollView
{
override func setContentOffset(_ contentOffset: CGPoint, animated: Bool) {
// restrict movement to vertical only
let newOffset = CGPoint(x: 0, y: contentOffset.y)
//only scroll if scroll direction is downwards
if newOffset.y > self.contentOffset.y
{
super.setContentOffset(newOffset, animated: animated)
}
}
}
0
source to share