Generic Instance Method

updating(_:body:)

Updates the provided gesture state property as the gesture’s value changes.

Declaration

func updating<State>(_ state: GestureState<State>, body: @escaping ((), inout State, inout Transaction) -> Void) -> GestureStateGesture<TapGesture, State>

Parameters

state

A binding to a view’s GestureState property.

body

The callback that SwiftUI invokes as the gesture’s value changes. Its currentState parameter is the updated state of the gesture. The gestureState parameter is the previous state of the gesture, and the transaction is the context of the gesture.

Return Value

A version of the gesture that updates the provided state as the originating gesture’s value changes, and that resets the state to its initial value when the users cancels or ends the gesture.

Discussion

Use this callback to update transient UI state as described in Adding Interactivity with Gestures.

See Also

Performing the Gesture

func onEnded((()) -> Void) -> _EndedGesture<TapGesture>

Adds an action to perform when the gesture ends.

typealias TapGesture.Value

A type that describes the value of a tap gesture.