I am trying to implement a scroll view that snaps to points when scrolling .
All the messages that I saw about snapping to the after point, the user finished dragging and dropping the scroll. I want it to be attached while dragging.
So far I have this to stop the inertia after the drag and it works fine:
func scrollViewWillEndDragging(scrollView: UIScrollView, withVelocity velocity: CGPoint, targetContentOffset: UnsafeMutablePointer<CGPoint>) { targetContentOffset.memory = scrollView.contentOffset }
I tried this but did not work as desired:
var scrollSnapHeight : CGFloat = myScrollView.contentSize.height/10
scrollViewDidScroll:
func scrollViewDidScroll(scrollView: UIScrollView) { let remainder : CGFloat = scrollView.contentOffset.y % scrollSnapHeight var scrollPoint : CGPoint = scrollView.contentOffset if remainder != 0 && scrollView.dragging { if self.lastOffset > scrollView.contentOffset.y
source share