title: SWIFTUI How to capture VStack height with geometry (after the VStack was displayed)?
body: <p>I'd like to ask you some help. I'm trying to capture <strong>VStack height</strong> using <strong>geometry</strong> and then based on that <strong>VStack height</strong> value, calculate its child element's height (inside VStack).</p>
  
  <p><a href="https://i.stack.imgur.com/Njast.png" rel="nofollow noreferrer">Image of my current view of VStack</a></p>
  
  <p>I used <strong>.frame</strong> outside of VStack to fill the whole screen. Then I used <strong>.borde</strong>r to visually check if it actually fills the screen <strong>(it works fine)</strong></p>
  
  <p><code>.frame(minWidth: 0, maxWidth: .infinity, minHeight: 0, maxHeight: .infinity, alignment: Alignment.topLeading)</code></p>
  
  <p>The problem can be seen inside the VStack, the height is displayed as GCFloat 734. Even though the border size is <strong>a lot bigger</strong>.</p>
  
  <pre><code>struct BodyView: View {
      @State var stackHeight : CGFloat = 0
  
      var body: some View {
          GeometryReader { geometry in
              VStack {
                  Text("VStack size: \(self.stackHeight)")
                      .bold()
                      .frame(maxWidth: .infinity, alignment: .leading)
                      .padding(.horizontal)
                      .background(Color.green)
  
              }
              .frame(minWidth: 0, maxWidth: .infinity, minHeight: 0, maxHeight: .infinity, alignment: Alignment.topLeading)
              .onAppear{
                  self.stackHeight = geometry.size.height
              }
              .border(Color.purple, width: 5)
          }
      }
  }
  
  struct BodyView_Previews: PreviewProvider {
      static var previews: some View {
          BodyView()
      }
  }
  </code></pre>
  
  <p>How could I capture the actual size of the VStack when it finishes loading?<br>
  When I trigger (onAppear) the VStack height appears correct, however I need it to be captured instantly.</p>