Latest 2.0.0
Homepage https://github.com/dclelland/MultitouchGestureRecognizer
License MIT
Platforms ios 8.0, requires ARC
Authors

MultitouchGestureRecognizer is a UIGestureRecognizer subclass providing a richer API for working with multiple touches.

Demo project available in the Multitouch directory.

Installation:

pod 'MultitouchGestureRecognizer', '~> 2.0'

Usage:

let gestureRecognizer = MultitouchGestureRecognizer()
gestureRecognizer.delegate = self
view.addGestureRecognizer(gestureRecognizer)

Features:

✓ Maximum touch count setting and stack/queue option:

// Only register the five touches received first:
gestureRecognizer.mode = .stack
gestureRecognizer.count = 5

// Only register the one touch received last:
gestureRecognizer.mode = .queue
gestureRecognizer.count = 1

✓ Sustain setting for retaining touches at the end of a gesture (ideal for, say, implementing a piano keyboard with a sustain function)

gestureRecognizer.sustain = true

✓ Delegate protocol methods for individual touches:

func multitouchGestureRecognizer(_ gestureRecognizer: MultitouchGestureRecognizer, touchDidBegin touch: UITouch) {
    print("Touch started")
}

func multitouchGestureRecognizer(_ gestureRecognizer: MultitouchGestureRecognizer, touchDidMove touch: UITouch) {
    print("Touch updated")
}

func multitouchGestureRecognizer(_ gestureRecognizer: MultitouchGestureRecognizer, touchDidCancel touch: UITouch) {
    print("Touch cancelled")
}

func multitouchGestureRecognizer(_ gestureRecognizer: MultitouchGestureRecognizer, touchDidEnd touch: UITouch) {
    print("Touch finished")
}

✓ Keeps track of the gesture’s state and touches:

if (gestureRecognizer.multitouchState == .live) {
    print("Gesture recognizer is currently receiving touches:", gestureRecognizer.touches)
}

✓ Centroid helper

print(multitouchGestureRecognizer.centroid) // Prints the average of all touches

Todo:

  • Make GIF preview
  • Publish to Carthage
  • Publish to Cocoa controls

Latest podspec

{
    "name": "MultitouchGestureRecognizer",
    "version": "2.0.0",
    "summary": "MultitouchGestureRecognizer is a UIGestureRecognizer subclass providing a richer API for working with multiple touches.",
    "homepage": "https://github.com/dclelland/MultitouchGestureRecognizer",
    "license": {
        "type": "MIT"
    },
    "authors": {
        "Daniel Clelland": "[email protected]"
    },
    "source": {
        "git": "https://github.com/dclelland/MultitouchGestureRecognizer.git",
        "tag": "2.0.0"
    },
    "platforms": {
        "ios": "8.0"
    },
    "ios": {
        "source_files": "MultitouchGestureRecognizer.swift"
    },
    "requires_arc": true,
    "pushed_with_swift_version": "3.0"
}

Pin It on Pinterest

Share This