Class

UIPanGestureRecognizer

A discrete gesture recognizer that interprets panning gestures.

Declaration

class UIPanGestureRecognizer : UIGestureRecognizer

Overview

UIPanGestureRecognizer is a concrete subclass of UIGestureRecognizer. Clients of this class can, in their action methods, query the UIPanGestureRecognizer object for the current translation of the gesture (translation(in:)) and the velocity of the translation (velocity(in:)). They can specify a view’s coordinate system to use for the translation and velocity values. Clients can also reset the translation to a desired value.

The user must press one or more fingers on a view while panning it. A panning gesture is continuous. It begins (UIGestureRecognizer.State.began) when the user moves the minimum number of fingers allowed (minimumNumberOfTouches) enough distance for recognition as a pan. It changes (UIGestureRecognizer.State.changed) when the user moves a finger while pressing with the minimum number of fingers. It ends (UIGestureRecognizer.State.ended) when the user lifts all fingers.

Topics

Configuring the Gesture Recognizer

var maximumNumberOfTouches: Int

The maximum number of fingers that can touch the view for gesture recognition.

var minimumNumberOfTouches: Int

The minimum number of fingers that can touch the view for gesture recognition.

Tracking the Location and Velocity of the Gesture

func translation(in: UIView?) -> CGPoint

Interprets the pan gesture in the coordinate system of the specified view.

func setTranslation(CGPoint, in: UIView?)

Sets the translation value in the coordinate system of the specified view.

func velocity(in: UIView?) -> CGPoint

Interprets the velocity of the pan gesture in the coordinate system of the specified view.

Tracking Scroll Events

var allowedScrollTypesMask: UIScrollTypeMask

A scroll type mask that enables recognition of scroll events.

Relationships

Inherits From

Conforms To

See Also

Standard Gestures

Handling UIKit Gestures

Use gesture recognizers to simplify touch handling and create a consistent user experience.

Coordinating Multiple Gesture Recognizers

Discover how to use multiple gesture recognizers on the same view.

class UIHoverGestureRecognizer

A discrete gesture recognizer that interprets pointer movement over a view.

class UILongPressGestureRecognizer

A discrete gesture recognizer that interprets long-press gestures.

class UIPinchGestureRecognizer

A discrete gesture recognizer that interprets pinching gestures involving two touches.

class UIRotationGestureRecognizer

A discrete gesture recognizer that interprets rotation gestures involving two touches.

class UIScreenEdgePanGestureRecognizer

A discrete gesture recognizer that interprets panning gestures that start near an edge of the screen.

class UISwipeGestureRecognizer

A discrete gesture recognizer that interprets swiping gestures in one or more directions.

class UITapGestureRecognizer

A discrete gesture recognizer that interprets single or multiple taps.