I am trying to guarantee that regardless of the image's dimensions, it won't overlap its neighbor sitting above it vertically.
Here is the code I used.
import SwiftUI
struct CardDetailView: View {
var body: some View {
ZStack {
Color.black
.edgesIgnoringSafeArea(.all)
Image(.darkColorShade)
.resizable()
.edgesIgnoringSafeArea(.all)
ScrollView {
VStack {
Text("Two of Cups".capitalized)
.font(.largeTitle)
.foregroundColor(.white)
// Spacer(minLength: 100)
Image(uiImage: .cardDemo)
.resizable()
.aspectRatio(contentMode: .fill)
.frame(width: 170, height: 150)
}
}
}
}
}
struct CardDetailView_Previews: PreviewProvider {
static var previews: some View {
CardDetailView()
}
}
When I uncomment the Spacer, it adjusts to the location I want. The Image should appear vertically below the text because it comes after the text in a VStack.
When the spacer is commented, the image overlaps its neighbor if its frame width exceeds its height. Why is that?
I am just trying to produce a predictable and reliable space between two different views. I shouldn't just tweak it to appear correct without understanding what is happening. I also tried setting the background of Image View to red, but that didn't give me any clues to what was happening.

