UIScrollView snap-to-position while scrolling
<p>I am trying to implement a scroll view that snaps to points <strong>while scrolling</strong>.</p>

<p>All the posts here I've seen about snapping to a point 'after' the user has ended dragging the scroll.  I want to make it snap during dragging.</p>

<p>So far I have this to stop the inertia after dragging and it works fine:</p>

<pre><code>func scrollViewWillEndDragging(scrollView: UIScrollView, withVelocity velocity: CGPoint, targetContentOffset: UnsafeMutablePointer&lt;CGPoint&gt;) {
      targetContentOffset.memory = scrollView.contentOffset
}
</code></pre>

<p>I tried this but not working as desired:</p>

<pre><code>    var scrollSnapHeight : CGFloat = myScrollView.contentSize.height/10
</code></pre>

<p>scrollViewDidScroll:</p>

<pre><code>func scrollViewDidScroll(scrollView: UIScrollView) {
    let remainder : CGFloat = scrollView.contentOffset.y % scrollSnapHeight
    var scrollPoint : CGPoint = scrollView.contentOffset
    if remainder != 0 &amp;&amp; scrollView.dragging
    {
        if self.lastOffset &gt; scrollView.contentOffset.y //Scrolling Down
        {
            scrollPoint.y += (scrollSnapHeight - remainder)
            NSLog("scrollDown")
        }
        else //Scrolling Up
        {
            scrollPoint.y -= (scrollSnapHeight - remainder)
        }
        scrollView .setContentOffset(scrollPoint, animated: true)
    }
    self.lastOffset = scrollView.contentOffset.y;
}
</code></pre>