I'm trying to insert 3 rectangles inside my scrollView precisely 2 horizontally and 1 vertically. I need all three rectangles to respect the same width. Horizontally everything works fine and adapts to all devices instead of the single rectangle vertically I can't find the right way to get the same width result as the horizontal ones
This is the code I used.. can you help me understand if this is the right way to get the result I want or if I have to totally change the way?
var body: some View {
ScrollView(.vertical) {
VStack(spacing: 32) {
Spacer()
VStack {
HStack {
ForEach(1...2, id: \.self) { cards in
ZStack(alignment: .center) {
RoundedRectangle(cornerRadius: 10)
.stroke(lineWidth: 0.5)
VStack(alignment: .center, spacing: 16) {
Image(systemName: "megaphone")
Text("Text")
Text("Text")
.multilineTextAlignment(.center)
Image(systemName: "circle")
}
.padding()
}
}
}
ZStack(alignment: .center) {
RoundedRectangle(cornerRadius: 10)
.stroke(lineWidth: 0.5)
VStack(alignment: .center, spacing: 16) {
Image(systemName: "megaphone")
Text("Text")
Text("Text")
.multilineTextAlignment(.center)
Image(systemName: "circle")
}
.padding()
}
}
}
}
}