UIControl
extension UIControl
-
Provide a handler that will be called for UIControlEvents option passed in.
To use this method just call it from a UIControl instance like so:
myButton.on(.touchUpInside) { control, event in <# button tapped code #> }Warning
You must only pass in one UIControlEvents option to this method. Providing something such as
[.touchUpOutside, .touchUpInside]is currently not supported yet.Declaration
Swift
@discardableResult public func on(_ events: UIControl.Event, handler: @escaping EventHandler) -> SelfParameters
eventsThe UIControlEvents option to listen for
handlerThe callback closure you wish to be called for this event
Return Value
itself so you can daisy chain the other event handler calls
View on GitHub
UIControl Extension Reference