UIView

extension UIView
  • A convenience method that adds a UITapGestureRecognizer to a view, while also passing default values to its convenience initializer.

    Declaration

    Swift

    @discardableResult
    public func addTapGesture(tapsRequired: Int = 1,
                              touchesRequired: Int = 1,
                              handler: @escaping (_ gesture: UITapGestureRecognizer) -> Void) -> UITapGestureRecognizer

    Parameters

    tapsRequired

    Defaults UITapGestureRecognizer’s numberOfTapsRequired property value

    touchesRequired

    Defaults UITapGestureRecognizer’s numberOfTouchesRequired property value

    handler

    The closure that is called when the gesture is recognized

    Return Value

    The gesture that was created so that it can be used to daisy chain other customizations

  • A convenience method that adds a UILongPressGestureRecognizer to a view, while also passing default values to its convenience initializer.

    Declaration

    Swift

    @discardableResult
    public func addLongPressGesture(tapsRequired: Int = 0,
                                    touchesRequired: Int = 1,
                                    minDuration: CFTimeInterval = 0.5,
                                    allowableMovement: CGFloat = 10,
                                    handler: @escaping (_ gesture: UILongPressGestureRecognizer) -> Void) -> UILongPressGestureRecognizer

    Parameters

    tapsRequired

    Defaults UILongPressGestureRecognizer’s numberOfTapsRequired property value

    touchesRequired

    Defaults UILongPressGestureRecognizer’s numberOfTouchesRequired property value

    minDuration

    Defaults UILongPressGestureRecognizer’s minimumPressDuration property value

    allowableMovement

    Defaults UILongPressGestureRecognizer’s allowableMovement property value

    handler

    The closure that is called when the gesture is recognized

    Return Value

    The gesture that was created so that it can be used to daisy chain other customizations

  • A convenience method that adds a UIPinchGestureRecognizer to a view, while also passing default values to its convenience initializer.

    Declaration

    Swift

    @discardableResult
    public func addPinchGesture(handler: @escaping (_ gesture: UIPinchGestureRecognizer) -> Void) -> UIPinchGestureRecognizer

    Parameters

    handler

    The closure that is called when the gesture is recognized

    Return Value

    The gesture that was created so that it can be used to daisy chain other customizations

  • A convenience method that adds a UISwipeGestureRecognizer to a view, while also passing default values to its convenience initializer.

    Declaration

    Swift

    @discardableResult
    public func addSwipeGesture(direction: UISwipeGestureRecognizer.Direction = .right,
                                touchesRequired: Int = 1,
                                handler: @escaping (_ gesture: UISwipeGestureRecognizer) -> Void) -> UISwipeGestureRecognizer

    Parameters

    direction

    Defaults UISwipeGestureRecognizer’s direction property value

    touchesRequired

    Defaults UISwipeGestureRecognizer’s numberOfTouchesRequired property value

    handler

    The closure that is called when the gesture is recognized

    Return Value

    The gesture that was created so that it can be used to daisy chain other customizations

  • A convenience method that adds a UIRotationGestureRecognizer to a view, while also passing default values to its convenience initializer.

    Declaration

    Swift

    @discardableResult
    public func addRotationGesture(handler: @escaping (_ gesture: UIRotationGestureRecognizer) -> Void) -> UIRotationGestureRecognizer

    Parameters

    handler

    The closure that is called when the gesture is recognized

    Return Value

    The gesture that was created so that it can be used to daisy chain other customizations

  • A convenience method that adds a UIPanGestureRecognizer to a view, while also passing default values to its convenience initializer.

    Declaration

    Swift

    @discardableResult
    public func addPanGesture(minTouches: Int = 1,
                              maxTouches: Int = .max,
                              handler: @escaping (_ gesture: UIPanGestureRecognizer) -> Void) -> UIPanGestureRecognizer

    Parameters

    minTouches

    Defaults UIPanGestureRecognizer’s minimumNumberOfTouches property value

    maxTouches

    Defaults UIPanGestureRecognizer’s maximumNumberOfTouches property value

    handler

    The closure that is called when the gesture is recognized

    Return Value

    The gesture that was created so that it can be used to daisy chain other customizations

  • A convenience method that adds a UIScreenEdgePanGestureRecognizer to a view, while also passing default values to its convenience initializer.

    Declaration

    Swift

    @discardableResult
    public func addScreenEdgePanGesture(edges: UIRectEdge = .all,
                                        handler: @escaping (_ gesture: UIScreenEdgePanGestureRecognizer) -> Void) -> UIScreenEdgePanGestureRecognizer

    Parameters

    edges

    Defaults UIScreenEdgePanGestureRecognizer’s edges property value

    handler

    The closure that is called when the gesture is recognized

    Return Value

    The gesture that was created so that it can be used to daisy chain other customizations