GitPedia

GestureRecognizerClosures

Closure support for handling gesture recognizers in Swift.

From marcbaldwin·Updated June 13, 2026·View on GitHub·

[Closure](http://developer.apple.com/library/ios/documentation/Swift/Conceptual/Swift_Programming_Language/Closures.html) handlers for gesture recognizers, controls and bar button items. The project is written primarily in Swift, distributed under the MIT License license, first published in 2015. Key topics include: cocoapods, gesture-recognizer, pan, swift, swipe.

Latest release: 6.0.0
June 10, 2026View Changelog →

Gesture Recognizer Closures

Swift 5
Platform
License
Swift Package Manager

Closure handlers for gesture recognizers, controls and bar button items.

GestureRecognizerClosures supports

Gesture Recognizer Examples

Example of handling a single tap

Swift
view.onTap { _ in // Do something }

Example of handling a double tap

Swift
view.onDoubleTap { _ in // Do something }

Example of handling a long press

Swift
view.onLongPress { _ in // Do something }

Example of handling a pinch

Swift
view.onPinch { pinch in // Do something }

Example of handling a pan

Swift
view.onPan { pan in // Do something }

Example of handling a rotation

Swift
view.onRotate { rotate in // Do something }

Example of handling a screen edge pan

Swift
view.onScreenEdgePan { _ in // Do something }

Example of handling a swipe left

Swift
view.onSwipeLeft { _ in // Do something }

Example of handling a swipe right

Swift
view.onSwipeRight { _ in // Do something }

Example of handling a swipe up

Swift
view.onSwipeUp { _ in // Do something }

Example of handling a swipe down

Swift
view.onSwipeDown { _ in // Do something }

Bar Button Item Example

Swift
let barButtonItem = UIBarButtonItem(title: "Save", style: .Plain) { [unowned self] _ in self.save() }

Control Example

Swift
slider.on(.ValueChanged) { [unowned self] _ in self.volume = self.slider.value }

Installation

Use Swift Package Manager

Swift Package Manager is the recommended way to install GestureRecognizerClosures.

In Xcode, go to File ▸ Add Package Dependencies… and enter the repository URL:

https://github.com/marcbaldwin/GestureRecognizerClosures.git

Or add it to the dependencies of your Package.swift:

swift
dependencies: [ .package(url: "https://github.com/marcbaldwin/GestureRecognizerClosures.git", from: "5.0.0"), ]

Then add "GestureRecognizerClosures" to your target's dependencies.

Change Log

You can view the change log here.

Contributors

Showing top 2 contributors by commit count.

View all contributors on GitHub →

This article is auto-generated from marcbaldwin/GestureRecognizerClosures via the GitHub API.Last fetched: 6/24/2026