Magnification gesture to scale ScrollView's content.

Hello!

I am trying out new SwiftUI and I have to say that I love it, but I've got some problems implementing few features.
First issue is that I am not sure how can I scale content of ScrollView, to make content of that View smaller, but there would be more subviews visible.

Here's my code:
Code Block swift
@State private var scale: CGFloat = 1.0
var body: some View {
ScrollView([.horizontal]) {
HStack(alignment: .top) {
ForEach(0..<5, id: \.self) { _ in
ScrollView(.vertical) {
LazyVGrid(columns: [GridItem(.fixed(300), spacing: 10)], spacing: 10) {
ForEach(0..<5, id: \.self) { _ in
Rectangle()
.frame(width: 300, height: 300, alignment: .center)
}
}
}
.padding(.leading, 10)
}
}
.scaleEffect(scale)
}
.gesture(
MagnificationGesture()
.onChanged { value  in
scale = value.magnitude
})
}
}


If You paste that code to a project, You will see that app scales whole ScrollView, not its content.

And when we're talking about gestures, I would really appreciate if someone would share here how can I prioritize the gestures.

Thanks for reading!

I'm standing before the same problem. I have a view hierarchy inside a scrollview and i want to be able to zoom. Did you manage to implement this?

Try using the simultaneousGesture modifier instead of gesture.

https://developer.apple.com/documentation/swiftui/view/simultaneousgesture(_:including:)

Magnification gesture to scale ScrollView's content.
 
 
Q