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.

Beta
struct LongPressGesture

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

Beta
struct DragGesture

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

Beta
struct MagnificationGesture

A gesture that tracks how a magnification event sequence changes.

Beta
struct RotationGesture

A gesture that tracks how a rotation event sequence changes.

Beta

Combined Gestures

Composing SwiftUI Gestures

Combine gestures to create complex interactions.

struct SequenceGesture

A gesture type that sequences two subgestures.

Beta
struct SimultaneousGesture

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

Beta
struct ExclusiveGesture

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

Beta

Custom Gestures

protocol Gesture

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

Beta
struct AnyGesture

A type-erased gesture.

Beta

Dynamic View Properties

struct GestureState

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

Beta

See Also

Data and Events

State and Data Flow

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

Beta Software

This documentation contains preliminary information about an API or technology in development. This information is subject to change, and software implemented according to this documentation should be tested with final operating system software.

Learn more about using Apple's beta software