In SwiftUI, is there a way to have a parent view maintain a fixed size even if the child view is larger? In this example below, the parent grows to fit the contents of the child even if you explicitly set a frame size on the parent:
import SwiftUI
struct ContentView: View {
var body: some View {
ZStack {
ChildView()
VStack {
Text("Parent")
Spacer()
}
}
.frame(width: 100, height: 100)
.background(Color.red)
.border(Color.black)
}
}
struct ChildView: View {
var body: some View {
VStack {
Text("Child")
}
.frame(width: 200, height: 200)
.background(Color.blue)
}
}
I want the "Parent" text to stay within the frame of the parent, but it gets pushed up because the child view is larger.

