title: In SwiftUI, supporting iOS 14 and above, how do I get a ScrollView child view to ignore the safe area
body: <p>I have a VStack that contains a Rectangle. The Rectangle has an edgesIgnoresSafeArea(.top) view modifier on it to extend it through the top safe area.</p>
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>import SwiftUI
  
  struct ScrollViewSafeArea: View {
      var body: some View {
          ScrollView {
              VStack {
                  Rectangle()
                      .fill(Color.orange)
                      .frame(height: 200)
                      .edgesIgnoringSafeArea(.top)
  
                  Spacer()
              }
          }
          .background(Color.green.ignoresSafeArea())
      }
  }</code></pre>
  </div>
  </div>
  </p>
  <p><a href="https://i.stack.imgur.com/WKHtF.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/WKHtF.png" alt="Base View" /></a></p>
  <p>Nice!</p>
  <p>However, when I embed this inside a ScrollView, the Rectangle no longer extends through the safe area.</p>
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>import SwiftUI
  
  struct ScrollViewSafeArea: View {
      var body: some View {
          ScrollView {
              VStack {
                  Rectangle()
                      .fill(Color.orange)
                      .frame(height: 200)
                      .edgesIgnoringSafeArea(.top)
  
                  Spacer()
              }
          }
          .background(Color.green.ignoresSafeArea())
      }
  }</code></pre>
  </div>
  </div>
  </p>
  <p><a href="https://i.stack.imgur.com/EJiYy.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/EJiYy.png" alt="Embedded in a ScrollView" /></a></p>
  <p>I can add a negative top padding to the Rectangle to extend it through the safe area, but this feels hacky to me.</p>
  <p>Does anyone have a better way?</p>