title: How to animate navigationBarHidden in SwiftUI?
body: <pre><code>struct ContentView: View {
      @State var hideNavigationBar: Bool = false
      
      var body: some View {
          NavigationView {
              ScrollView {
                  VStack {
                      Rectangle().fill(Color.red).frame(height: 50)
                          .onTapGesture(count: 1, perform: {
                              withAnimation {
                                  self.hideNavigationBar.toggle()
                              }
                          })
                      VStack {
                          ForEach(1..&lt;50) { index in
                              HStack {
                                  Text(&quot;Sample Text&quot;)
                                  Spacer()
                              }
                          }
                      }
                  }
              }
              .navigationBarTitle(&quot;Browse&quot;)
              .navigationBarHidden(hideNavigationBar)
          }
      }
  }
  </code></pre>
  <p>When you tap the red rectangle it snaps the navigation bar away. I thought <code>withAnimation{}</code> would fix this, but it doesn't. In <code>UIKit</code> you would do something like this <code>navigationController?.setNavigationBarHidden(true, animated: true)</code>.</p>
  <p>Tested in xCode 12 beta 6 and xCode 11.7</p>