I am trying to place different subviews in a VStack with a fixed height. The last item should use all the remaining space/height. I found several topics about this, and the solution is simply to give the an maxHeight: .infinity.
While this works, I notices that this includes a spacing between this element and the other elements, while there is now spacing between the other elements.
It is no problem to remove this spacing by explicitly defining the stack with spacing: 0. However, why is there a space between this item and the others in the first place (while the is no spacing between the other items)?
Example
struct SomeView: View {
var body: some View {
VStack {
Text("Row 1")
.background(.red)
Text("Row 2")
.background(.green)
Text("Row 3")
.frame(maxHeight: .infinity)
.background(.blue)
}
.frame(maxWidth: 300, maxHeight: 400)
.background(.yellow)
}
}
While there is no spacing between Row 1 and Row 2, giving Row 3 a maxHeight results in an extra spacing. Why?

