Skip to content

Instantly share code, notes, and snippets.

@aybekckaya
Last active June 1, 2019 01:07
Show Gist options
  • Save aybekckaya/da5aaf20b44e0dba5299fb807a7b2df4 to your computer and use it in GitHub Desktop.
Save aybekckaya/da5aaf20b44e0dba5299fb807a7b2df4 to your computer and use it in GitHub Desktop.
class TapGestureReplicator:UIGestureRecognizer {
override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent) {
// Checking the count of touches .
// If number of finger used in gesture is not equal to one , then gesture should fail.
guard touches.count == 1 , let _ = touches.first else {
self.state = .failed
return
}
self.state = .began
}
override func touchesEnded(_ touches: Set<UITouch>, with event: UIEvent) {
guard touches.count == 1 , let _ = touches.first else {
self.state = .failed
return
}
self.state = .ended
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment