SwiftUI 如何在多级导航视图中停止列表的动画

SwiftUI How to stop the animation of List in Multi-level NavigationView

我只想在多级 NavigationView 中有多个 List 时停止动画。也许这不是 "ANIMATION",我只是想解决这个问题。

在 Xcode 版本 11.3.1 (11C504) + iOS 13.2

代码很简单,一看就知道是有线的

import SwiftUI

struct TestView: View {
    var body: some View {
        NavigationView {
            List {
                ForEach(1...4, id: \.self) {_ in
                    NavigationLink(destination: AView()) {
                        Text("root")
                    }
                }
            }
        }
    }
}

struct AView: View {
    var body: some View {
        List {
            ForEach(1...4, id: \.self) {_ in
                NavigationLink(destination: BView()) {
                    Text("aview")
                }
            }
        }
    }
}

struct BView: View {
    var body: some View {
        List {
            ForEach(1...4, id: \.self) {_ in
                NavigationLink(destination: BView()) {
                    Text("bview")
                }
            }
        }
    }
}

struct TestView_Previews: PreviewProvider {
    static var previews: some View {
        TestView()
    }
}

好的...我已经安装了这个倒霉的 Xcode 11.3.1...这是一个解决方案(或解决方法,无论如何)- 使用如下所示的显式 .listRowInsets示例(顺便说一句,插图可以是任何值)

List {
    ForEach(1...1000, id: \.self) {_ in
        NavigationLink(destination: BView()) {
            Text("bview")
        }
    }
    .listRowInsets(EdgeInsets(top: 0, leading: 20, bottom: 0, trailing: 20))
}

适用于任何动态列表