Closed 0si43 closed 2 years ago
I had used MagnificationGesture
like this
struct Canvas: View {
@GestureState var magnifyBy = 1.0
var magnification: some Gesture {
MagnificationGesture()
.updating($magnifyBy) { currentState, gestureState, _ in
gestureState = currentState
}
}
var tap: some Gesture {
// …
}
var body: some View {
PKCanvasViewWrapper(canvasView: $viewModel.canvasView)
.gesture(tap)
.scaleEffect(magnifyBy)
.gesture(magnification)
But, this result was not an expected behavior
Hopefully, zoom level stay after leaving fingers. A center point is touch point
I found the delegate method named viewForZooming(in:)
.
It's enabled pint-in/out action with setting minimum/maximumZoomScale!
Yes, this is perfect
I set minimum value, it was enable to pinch out. It was a bit of convenience……maybe…… But it will make difficult to back normal(x1.0) zoom scale.
I decided not to set minimum scale(and default value is 1.0). If user want to back normal scale, they just repeatedly pinch out.