manipulable(using:)
Allows the view to be manipulated using a manipulation gesture attached to a different view.
Declaration
nonisolated func manipulable(using gestureState: Manipulable.GestureState) -> some View
Parameters
- gestureState:
The manipulation gesture state that’s updated by a manipulation gesture added to a different view.
Return Value
A view that can be manipulated by a manipulation gesture attached to a different view.
Discussion
Use this view modifier alongside manipulationGesture(updating:coordinateSpace:operations:inertia:isEnabled:onChanged:) when you want to allow a person to manipulate a view by interacting with a different view.
In the following example, a person can begin a manipulation gesture attached to a deck of cards which, in turn, manipulates a single card instead of the entire deck:
struct CardDeck: View {
@State private var manipulationState = Manipulable.GestureState()
var body: some View {
ZStack {
Model3D(named: "CardDeck")
.manipulationGesture(updating: $manipulationState)
Model3D(named: "Card")
.manipulable(using: manipulationState)
.opacity(manipulationState.isActive ? 1 : 0)
}
}
}