-
Notifications
You must be signed in to change notification settings - Fork 30
Gestures
Nick Sarno edited this page Jan 13, 2024
·
5 revisions
Add a DragGesture to a View.
RoundedRectangle(cornerRadius: 10)
.frame(width: 300, height: 200)
.withDragGesture()
Customize the gesture with optional parameters.
RoundedRectangle(cornerRadius: 10)
.frame(width: 300, height: 200)
.withDragGesture(
[.vertical, .horizontal],
resets: true,
animation: .smooth,
rotationMultiplier: 1.1,
scaleMultiplier: 1.1,
onChanged: { dragOffset in
let tx = dragOffset.height
let ty = dragOffset.width
},
onEnded: { dragOffset in
let tx = dragOffset.height
let ty = dragOffset.width
}
)
Add a MagnificationGesture to a View.
RoundedRectangle(cornerRadius: 10)
.frame(width: 300, height: 200)
. withMagnificationGesture()
Customize the gesture with optional parameters.
RoundedRectangle(cornerRadius: 10)
.frame(width: 300, height: 200)
.withMagnificationGesture(resets: false, animation: .spring(), scaleMultiplier: 1.1) { scale in
}
Add a RotationGesture to a View.
RoundedRectangle(cornerRadius: 10)
.frame(width: 300, height: 200)
. withRotationGesture()
Customize the gesture with optional parameters.
RoundedRectangle(cornerRadius: 10)
.frame(width: 300, height: 200)
.withRotationGesture(resets: false, animation: .spring()) { angle in
}