UIGestureRecognizer

extension UIGestureRecognizer

Extend UIGestureRecognizer to accept closures for events.

  • Type of closure to invoke when gesture fires.

    Declaration

    Swift

    public typealias Closure = (AnyObject) -> Void
  • Add a closure to the gesture recognizer.

    Declaration

    Swift

    @discardableResult
    public func addClosure(
      for controlEvents: UIControl.Event = .touchUpInside, _ closure: @escaping Closure
    ) -> UUID

    Parameters

    controlEvents

    the event to register for

    closure

    the closure to call when the event happens

    Return Value

    token to be used when removing a registration

  • Remove a closure registration.

    Declaration

    Swift

    public func removeClosure(key: UUID, for controlEvents: UIControl.Event)

    Parameters

    key

    the token that was obtained from addClosure call

    controlEvents

    the event that was registered for in the addClosure call