Closure handlers for gesture recognizers, controls and bar button items.
GestureRecognizerClosures supports
UIGestureRecognizerUILongPressGestureRecognizerUIPinchGestureRecognizerUIRotationGestureRecognizerUISwipeGestureRecognizerUITapGestureRecognizerUIPanGestureRecognizerUIBarButtonItemUIControl
Example of handling a single tap
view.onTap { _ in
// Do something
}Example of handling a double tap
view.onDoubleTap { _ in
// Do something
}Example of handling a long press
view.onLongPress { _ in
// Do something
}Example of handling a pinch
view.onPinch { pinch in
// Do something
}Example of handling a pan
view.onPan { pan in
// Do something
}Example of handling a rotation
view.onRotate { rotate in
// Do something
}Example of handling a screen edge pan
view.onScreenEdgePan { _ in
// Do something
}Example of handling a swipe left
view.onSwipeLeft { _ in
// Do something
}Example of handling a swipe right
view.onSwipeRight { _ in
// Do something
}Example of handling a swipe up
view.onSwipeUp { _ in
// Do something
}Example of handling a swipe down
view.onSwipeDown { _ in
// Do something
}let barButtonItem = UIBarButtonItem(title: "Save", style: .Plain) { [unowned self] _ in
self.save()
}slider.on(.ValueChanged) { [unowned self] _ in
self.volume = self.slider.value
}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:
dependencies: [
.package(url: "https://github.com/marcbaldwin/GestureRecognizerClosures.git", from: "5.0.0"),
]Then add "GestureRecognizerClosures" to your target's dependencies.
You can view the change log here.