Created
December 11, 2015 08:32
-
-
Save haldun/cd920f91fea26e930824 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
protocol TimedTapGestureRecognizerDelegate: class { | |
func delayInSecondsForTimedTapGestureRecognizer(recognizer: TimedTapGestureRecognizer) -> Double | |
} | |
final class TimedTapGestureRecognizer: UITapGestureRecognizer { | |
weak var timedTapGestureRecognizerDelegate: TimedTapGestureRecognizerDelegate? | |
override func touchesBegan(touches: Set<UITouch>, withEvent event: UIEvent) { | |
super.touchesBegan(touches, withEvent: event) | |
let delayDuration = timedTapGestureRecognizerDelegate?.delayInSecondsForTimedTapGestureRecognizer(self) ?? 0.4 | |
delay(delayDuration) { | |
if self.state != .Recognized { | |
self.state = .Failed | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment