How to disable NavigationView push and pop animations

前端 未结 2 466
醉酒成梦
醉酒成梦 2021-01-01 17:25

Given this simple NavigationView:

struct ContentView : View {
    var body: some View {
        Naviga         


        
2条回答
  •  梦谈多话
    2021-01-01 17:54

    Xcode 11.3:

    Right now there is no modifier to disable NavigationView animations.

    You can use your struct init() to disable animations, as below:

    struct ContentView : View {
    
        init(){
            UINavigationBar.setAnimationsEnabled(false)
        }
    
        var body: some View {
            NavigationView {
                VStack {
                    NavigationLink("Push Me", destination: Text("PUSHED VIEW"))
                }
            }
        }
    }
    

提交回复
热议问题