How are you doing?
Please consider the following code:
struct ContentView: View {
var body: some View {
NavigationView {
GeometryReader { geometry in
ZStack(alignment: .leading) {
ViewOne()
.frame(height: geometry.size.height / 2)
}
}
}
}
}
struct ViewOne: View {
init() {
print("View one init")
}
var body: some View {
VStack(alignment: .center) {
Text("This is View one")
.font(.system(size: 50))
}
}
}
My question is simple: Why is ViewOne built two times inside a GeometryReader and only once outside of a GeometryReader?
First, I thought that the view needed to be created once, and then a second time taking in consideration the GeometryReader sizes, however, if you have a more complex content within ViewOne, things get messy.
Any ideas??
Thanks for your time and help on this SwiftUI friends!!