Created
July 12, 2016 04:27
-
-
Save garohussenjian/78f42f1bab143e571c21d00c41439ded to your computer and use it in GitHub Desktop.
Stateful Gesture Recognizer subclass
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// PanSelectGestureRecognizer.swift | |
// | |
// Created by Garo Hussenjian on 6/24/15. | |
// | |
// | |
import UIKit | |
import UIKit.UIGestureRecognizerSubclass | |
class PanSelectGestureRecognizer: UIGestureRecognizer { | |
var selectionState: Bool? | |
override func touchesBegan(touches: Set<UITouch>, withEvent event: UIEvent) { | |
super.touchesBegan(touches, withEvent:event); | |
if state == .Possible { | |
state = .Began; | |
} | |
} | |
override func touchesMoved(touches: Set<UITouch>, withEvent event: UIEvent) { | |
super.touchesMoved(touches, withEvent: event) | |
state = .Changed | |
} | |
override func touchesEnded(touches: Set<UITouch>, withEvent event: UIEvent) { | |
super.touchesEnded(touches, withEvent: event) | |
state = .Ended | |
} | |
override func touchesCancelled(touches: Set<UITouch>, withEvent event: UIEvent) { | |
super.touchesCancelled(touches, withEvent: event) | |
state = .Cancelled | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Here's how this is integrated at the callback site: