Latest 0.1.0
License MIT
Platforms ios 8.0

CI Status

A nicer approach to touch events

Adding a gesture recognizer programmatically is a very common operation. In particlar, it’s not rare that you would need to respond to touchDown, touchUpIside, touchUpOutside events occurring on some UI components.

This class addresses this specific case by providing a closure chaining syntax which I personally prefer.

With this class you will be able to:

  1. add/remove a tap gesture recognizer to any view
  2. define the closures associated to the touchDown, touchUpInside, touchUpOutside events


Adding the gesture recognizer to a view is straightforward:

RSGestureRecognizer().add(to: view)
    .onTouchDown { (recognizer) in 
        // touch down behaviour
    .onTouchUpInside { (recognizer) in
        // touch up inside behaviour
    .onTouchUpOutside { (recognizer) in
        // touch up outside behaviour

Closures are optional so it’s possible to assign only the behaviour needed:

RSGestureRecognizer().add(to: view)
    .onTouchDown { (recognizer) in 
        // touch down behaviour

You can remove the tap gesture anytime by calling the remove() function on its instance, if an instance reference is not available it’s possible to retrieve it by inspecting a view directly with the static find(in:) function:

RSTapGesture.find(in: view)?.remove()


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

pod 'RSTapGesture'


terrordrummer, [email protected]


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

Latest podspec

    "name": "RSTapGesture",
    "version": "0.1.0",
    "summary": "A nicer approach to touch events.",
    "swift_version": "4.2",
    "description": "TODO: Add long description of the pod here.",
    "homepage": "",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    "authors": {
        "terrordrummer": "[email protected]"
    "source": {
        "git": "",
        "tag": "0.1.0"
    "platforms": {
        "ios": "8.0"
    "source_files": "RSTapGesture/Classes/**/*"

Pin It on Pinterest

Share This