One Logo Pool Ball
SwiftUI · IOS API REFERENCE

GestureState

struct · iOS 13.0+ · SDK 27.1

@propertyWrapper @frozen struct GestureState<Value>

A property wrapper type that updates a property while the user performs a gesture and resets the property back to its initial state when the gesture ends. Declare a property as `@GestureState`, pass as a binding to it as a parameter to a gesture's ``Gesture/updating(_:body:)`` callback, and receive updates to it. A property that's declared as `@GestureState` implicitly resets when the gesture becomes inactive, making it suitable for tracking transient state. Add a long-press gesture to a ``Circle``, and update the interface during the gesture by declaring a property as `@GestureState`: struct SimpleLongPressGestureView: View { @GestureState private var isDetectingLongPress = false var longPress: some Gesture { LongPressGesture(minimumDuration: 3) .updating($isDetectingLongPress) { currentState, gestureState, transaction in gestureState = currentState } } var body: some View { Circle() .fill(self.isDetectingLongPress ? Color.red : Color.green) .frame(width: 100, height: 100, alignment: .center) .gesture(longPress) } }

Members (0)

This type has no directly callable members in this snapshot. See the framework’s skipped declarations for unsupported APIs.

Skipped declarations

2 declarations were excluded from these bindings. Each reason comes from the generator or the iOS SDK compiler.

GestureState.init(resetTransaction:)

The containing type needs Swift generic type arguments. (no canonical witness for Value)

GestureState.init(reset:)

This declaration needs Swift generic type arguments. (no canonical witness for Value)

All SwiftUI types →