UIButton

extension UIButton
  • A convenience method wrapping a typical use for UIButton’s UIControlEvents.touchUpInside event. This allows a parameterless closure to be called when the UIButton is tapped.


    An example of calling this method:

    myButton.onTap {
        <# button tapped code #>
    }
    

    Declaration

    Swift

    @discardableResult
    public func onTap(handler: @escaping () -> Void) -> Self

    Parameters

    handler

    The closure to be called on the button tapped event

    Return Value

    itself so you can daisy chain the other event handler calls