Last active
December 13, 2018 19:43
-
-
Save radutzan/893d3dc5f44ea79aff232db16988a47c to your computer and use it in GitHub Desktop.
A way to declare a UIButton's tap, touch down, and "touch lift" actions through closure properties. See comments for more info.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
An evolution of the target-action model for the Swift era. Target is always
self
, since other objects can easily be called from inside the closure. This allows for faster prototyping, potentially cleaner class interfaces with less "buttonTapped
" methods, and a pattern closer to Swift property observers.tapAction
is equivalent to an action called on.TouchUpInside
touchDownAction
is equivalent to an action called on.TouchDown
touchLiftAction
is equivalent to an action called on either.TouchUpInside
or.TouchCancel
Example call site usage: