title: Scroll Views background colour when placed in a Navigation Stack in SwiftUI
body: <p>I have two scroll views placed in a <code>NavigationView</code>. I want both the ScrollViews to inherit the colour as mentioned in the <code>onAppear</code> modifier.</p>
  <p>However, when I navigate to the second ScrollView and go back to the first ScrollView, the first view inherits the second ScrollView colour.</p>
  <pre><code>struct ScrollView1: View {
      var body: some View {
          NavigationView {
              ScrollView {
                  NavigationLink(destination: ScrollView2()) {
                      Text(&quot;First View&quot;).padding()
                  }.frame(maxWidth: .infinity)
              }.navigationBarTitle(&quot;First&quot;)
              .onAppear {
                  UIScrollView.appearance().backgroundColor = UIColor.green
              }
          }
      }
  }
  
  struct ScrollView2: View {
      var body: some View {
          ScrollView {
              Text(&quot;Second View&quot;).frame(maxWidth: .infinity)
          }
          .onAppear {
              UIScrollView.appearance().backgroundColor = UIColor.gray
          }
      }
  }
  </code></pre>
  <p>Does anyone know how my first ScrollView will always inherit green and second, gray colour?</p>
  <p>Adding ScrollView colour by wrapping inside a ZStack will not collapse NavigationBar from large to inline while scrolling.</p>
  <p>Is there any other solution to achieve both i.e, preserving the navigationBar bounce behaviour along with ScrollView colour.</p>