Skip to content

Instantly share code, notes, and snippets.

@longlongjump
Created March 9, 2016 13:50
Show Gist options
  • Save longlongjump/74fa1ef3fb68b007b711 to your computer and use it in GitHub Desktop.
Save longlongjump/74fa1ef3fb68b007b711 to your computer and use it in GitHub Desktop.
class OverlayView: UIView {
weak var targetView: UIView?
override func touchesBegan(touches: Set<UITouch>, withEvent event: UIEvent?) {
super.touchesBegan(touches, withEvent: event)
targetView?.touchesBegan(touches, withEvent: event)
}
override func touchesMoved(touches: Set<UITouch>, withEvent event: UIEvent?) {
super.touchesMoved(touches, withEvent: event)
targetView?.touchesCancelled(touches, withEvent: event) // its important to cancel touch to proper unhighlight cell
}
override func touchesEnded(touches: Set<UITouch>, withEvent event: UIEvent?) {
super.touchesEnded(touches, withEvent: event)
targetView?.touchesEnded(touches, withEvent: event)
}
override func touchesCancelled(touches: Set<UITouch>?, withEvent event: UIEvent?) {
super.touchesCancelled(touches, withEvent: event)
targetView?.touchesCancelled(touches, withEvent: event)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment