我希望允许用户在SwiftUI中对图像进行缩小放大。我认为最好的方法是使用MagnificationGesture,然后,在回答之后,我得到了以下代码:
// outside of `var body: some View`
@State private var scale: Int = 1.0
@State private var lastScale: Int = 1.0
// Image
Image("dog")
.resizable()
.aspectRatio(contentMode: .fit)
.gesture(MagnificationGesture()