title: SwiftUI - Using GeometryReader Without Modifying The View Size
body: <p>I have a header view which extends its background to be under the status bar using <code>edgesIgnoringSafeArea</code>. To align the content/subviews of the header view correctly, I need the <code>safeAreaInsets</code> from <code>GeometryReader</code>. However, when using <code>GeometryReader</code>, my view doesn't have a fitted size anymore. </p>
  
  <p><strong>Code without using <code>GeometryReader</code></strong></p>
  
  <pre><code>struct MyView : View {
      var body: some View {
          VStack(alignment: .leading) {
              CustomView()
          }
          .padding(.horizontal)
          .padding(.bottom, 64)
          .background(Color.blue)
      }
  }
  </code></pre>
  
  <p><strong>Preview</strong></p>
  
  <p><a href="https://i.stack.imgur.com/x8SGz.png" rel="noreferrer"><img src="https://i.stack.imgur.com/x8SGz.png" alt="Expected"></a></p>
  
  <p><strong>Code using <code>GeometryReader</code></strong></p>
  
  <pre><code>struct MyView : View {
      var body: some View {
          GeometryReader { geometry in
              VStack(alignment: .leading) {
                  CustomView()
              }
              .padding(.horizontal)
              .padding(.top, geometry.safeAreaInsets.top)
              .padding(.bottom, 64)
              .background(Color.blue)
              .fixedSize()
          }
      }
  }
  
  </code></pre>
  
  <p><strong>Preview</strong></p>
  
  <p><a href="https://i.stack.imgur.com/WXjcX.png" rel="noreferrer"><img src="https://i.stack.imgur.com/WXjcX.png" alt="enter image description here"></a></p>
  
  <p>Is there a way to use <code>GeometryReader</code> without modifying the underlying view size?</p>