In this example, the "hello" text is placed in the middle of the screen, as expected.
struct ContentView: View {
var body: some View {
GeometryReader { geo in
Text("hello")
.background(Color.green)
}
.background(Color.blue)
}
}
But when I move Text
to an extracted view, the "hello" text moves to the top left corner of the screen.
struct ContentView: View {
var body: some View {
GeometryReader { geo in
ExtractedView()
}
.background(Color.blue)
}
}
struct ExtractedView: View {
var body: some View {
Text("hello")
.background(Color.green)
}
}
Is this a bug, or an expected behavior I don't understand?