I have a problem trying to determine the height of a view inside a ScrollView
struct ContentView: View {
var body: some View {
ScrollView{
GeometryReader { geometry in
VStack{
ForEach(0..<90) { index in
Text("test \(geometry.size.height)")
}
}
}
}
}
}
geometry.size.height is always 10.000.
how can i correct this unexpected result?
Thanks so much!
I'm not sure where you're going with this.
GeometryReader
reads the size offered to the view, not the size of the view. You can find out how big the view is by putting aGeometryReader
in an.overlay
of theVStack
, because by the time the overlay is created, the size of theVStack
will have been established and that size will be offered to the overlay.