Latest 1.0.0
License MIT
Platforms ios 8.0




The example project includes an example of a UICollectionViewFlowLayout including support for sections and spacing. It also includes support for snapping to the left, middle and right edges.

Lets add snapping support to our UICollectionView Snaply In Action
The following code is all that’s required to setup the top preview on the right.
let collectionView = UICollectionView(frame: view.bounds, 
collectionViewLayout: UICollectionViewFlowLayout())

// The delegate will automatically forward all events 
// to you existing delegate so it won't break your code :)
let snap = Snap(scrollView: collectionView, edge: .Min, 
direction: .Horizontal, delegate: self)

var locations = [CGFloat]()
var widths = [CGFloat]()

for i in 0..

How does it work

If we take a look at the following image, the red lines represent points we want our scrollView to snap to, along a given edge. So you just need to specify these points and Snaply will handle the snapping behaviour for you. Including things like finding the closest point and ensuring overscroll doens’t occur.

To get started, you just need a single line in your project:

snap = Snap(scrollView: collectionView, edge: .Min, direction: .Horizontal, delegate: self)

This adds snapping to the specified collectionView, using the left edge as the snap point since we’re using a horizontal layout.

You may notice we also pass along the original delegate (if any). This allows Snaply to automatically forward all events back to the original delegate to ensure no existing behaviour is effected by dropping in Snaply :)


To run the example project, clone the repo, and run pod install from the Example directory first.


Snaply requires iOS 8+
The current version requires Swift 2.2


Snap is available through CocoaPods. To install
it, simply add the following line to your Podfile:

pod "Snaply"


@shaps on Twitter


Snap is available under the MIT license. See the LICENSE file for more info.

Latest podspec

    "name": "Snaply",
    "version": "1.0.0",
    "summary": "Drop-in snapping behaviour for any scroll/collection/table/view using arbitrary points!",
    "homepage": "",
    "screenshots": "",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    "authors": {
        "Shaps": "[email protected]"
    "source": {
        "git": "",
        "tag": "1.0.0"
    "social_media_url": "",
    "platforms": {
        "ios": "8.0"
    "source_files": "Snaply/Classes/**/*"

Pin It on Pinterest

Share This