Instance Property


The current state of the gesture recognizer.


var state: UIGestureRecognizer.State { get set }


The possible states a gesture recognizer can be in are represented by the constants of type UIGestureRecognizer.State. Some of these states are not applicable to discrete gestures. The read-only version of the state property is intended for clients of a gesture-recognizer class and not subclasses.

Special Considerations

Subclasses of UIGestureRecognizer must use a read-write version of the state property. They get this redeclaration when they import the UIGestureRecognizerSubclass.h header file:

@property(nonatomic,readwrite) UIGestureRecognizerState state;

Recognizers for discrete gestures transition from UIGestureRecognizer.State.possible to UIGestureRecognizer.State.failed or recognized. Recognizers for continuous gesture transition from UIGestureRecognizer.State.possible to these phases in the given order: UIGestureRecognizer.State.began, UIGestureRecognizer.State.changed, and UIGestureRecognizer.State.ended. If, however, they receive a cancellation touch, they should transition to UIGestureRecognizer.State.cancelled. If recognizers for continuous gestures can’t interpret a multi-touch sequence as their gesture, they transition to UIGestureRecognizer.State.failed.

See Also

Getting the Recognizer’s State and View

var view: UIView?

The view the gesture recognizer is attached to.

var isEnabled: Bool

A Boolean property that indicates whether the gesture recognizer is enabled.