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) -> Self

    Parameters

    events

    The UIControlEvents option to listen for

    handler

    The callback closure you wish to be called for this event

    Return Value

    itself so you can daisy chain the other event handler calls