Latest 0.1.0
Homepage https://github.com/terrordrummer/RSTapGesture
License MIT
Platforms ios 8.0
Authors

CI Status
Version
License
Platform

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

Example

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()

Installation

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

pod 'RSTapGesture'

Author

terrordrummer, [email protected]

License

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": "https://github.com/terrordrummer/RSTapGesture",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "terrordrummer": "[email protected]"
    },
    "source": {
        "git": "https://github.com/terrordrummer/RSTapGesture.git",
        "tag": "0.1.0"
    },
    "platforms": {
        "ios": "8.0"
    },
    "source_files": "RSTapGesture/Classes/**/*"
}

Pin It on Pinterest

Share This