I'm trying to zoom and pan on an Image in SwiftUI for a Catalyst app. There is no PanGesture, but ScrollView seems to work well on both iPad and Mac. I just can't scroll around on the magnified image.
struct TestScrollView: View {
@State var scale: CGFloat = 1.0
var body: some View {
VStack {
ScrollView([.horizontal,.vertical], showsIndicators: false) {
Image("image")
.resizable()
}
.gesture(MagnificationGesture()
.onChanged({ (scale) in
self.scale = scale
}))
.scaleEffect(self.scale)
}
}
}
And with the following code...
ScrollView([.horizontal,.vertical], showsIndicators: false) {
Image("large_image")
.resizable()
.gesture(MagnificationGesture()
.onChanged({ (scale) in
self.scale = scale
}))
.scaleEffect(self.scale)
}
...I get this:
It seems to scroll right a lot and it gets cut off on the left side.