I have a few VStacks in my SwiftUI ContentView and I'm wondering how calculate remaning vertical space at the bottom of screen. Reason is to draw chart there and I need to know y-axis scale. Thanks.
I have a few VStacks in my SwiftUI ContentView and I'm wondering how calculate remaning vertical space at the bottom of screen. Reason is to draw chart there and I need to know y-axis scale. Thanks.
Here is a demo of possible approach - use GeometryReader that consumes all available space and gives metrics
struct DemoView: View {
@State private var height = CGFloat.zero
var body: some View {
VStack {
View1()
View2()
// GeometryReader consumes all remaining space here
GeometryReader { gp in
// use gp.size here
}
}
}
}