Gestures

Define interactions from taps, clicks, and swipes to fine-grained gestures.

Overview

Respond to taps and gestures by adding gesture modifiers to your views. Create custom gestures by combining individual gestures simultaneously or in sequence, and specify actions to perform at each state of a gesture.

Topics

Basic Gestures

Adding Interactivity with Gestures

Use gesture modifiers to add interactivity to your app.

struct TapGesture

A gesture that ends once a specified number of tap event sequences have been recognized.

struct LongPressGesture

A gesture that ends once a long-press event sequence has been recognized.

struct DragGesture

A gesture that invokes an action as a drag event sequence changes.

struct MagnificationGesture

A gesture that tracks how a magnification event sequence changes.

struct RotationGesture

A gesture that tracks how a rotation event sequence changes.

Combined Gestures

Composing SwiftUI Gestures

Combine gestures to create complex interactions.

struct SequenceGesture

A gesture type that sequences two subgestures.

struct SimultaneousGesture

A container event handler that evaluates its two child gestures simultaneously.

struct ExclusiveGesture

A pair of gestures where only one can succeed, which gives precedence to the first of the pair.

Custom Gestures

protocol Gesture

An input gesture that matches a sequence of events and returns a stream of values.

struct AnyGesture

A type-erased gesture.

Dynamic View Properties

struct GestureState

A dynamic view property that stores state during performance of a gesture.

See Also

Data and Events

State and Data Flow

Control and respond to the flow of data and changes within your app’s models.