title: How to create animation with delay when dismiss view swiftui
body: <p>I used the following example ( <a href="https://stackoverflow.com/questions/56513568/ios-swiftui-pop-or-dismiss-view-programmatically">iOS SwiftUI: pop or dismiss view programmatically</a> ) in my code, but I don't know how to create an animation just like flipping a page and put several seconds delay when [Button] tapped.Does anyone know a solution?</p>
  
  <pre><code>struct DetailView: View {
      @Environment(\.presentationMode) var presentationMode: Binding&lt;PresentationMode&gt;
      var body: some View {
          Button(
              "Here is Detail View. Tap to go back.",
              action: {
  
                  //withAnimation(.linear(duration: 5).delay(5))// Error occurred in dalay.(Type of expression is ambiguous without more context)
                  withAnimation(.linear(duration: 5)) // not work 
                  {
                      self.presentationMode.wrappedValue.dismiss()
                  }
          }
          )
      }
  }
  
  struct RootView: View {
      var body: some View {
          VStack {
              NavigationLink(destination: DetailView())
              { Text("I am Root. Tap for Detail View.")
          }
      }
  }
  
  struct ContentView: View {
      var body: some View {
          NavigationView {
              RootView()
          }
      }
  }
  </code></pre>