SwiftUI NavigationView 未在视图中完全扩展

SwiftUI NavigationView Not Fully Extending In View

我在 SwiftUI 中使用 NavigationView 时遇到问题,它完全延伸到屏幕底部。

我在 中创建了一个简单的列表,它工作正常。但是,当我将它放在 NavigationView 中时,它会在底部创建一个灰色区域。我试过调整框架和其他一些东西都无济于事。我以前从没见过这个。任何帮助将不胜感激。

struct ListingView: View {
    var body: some View {
        List(0..<5) { item in
            Text("Test")
        }
    }
}

struct ListingView: View {
    var body: some View {
        NavigationView {
            List(0..<5) { item in
                Text("Test")
            }
        }
    }
}

struct ContentView: View {
    // PacificBlue Background Set Up.
    init() {
        UITabBar.appearance().isTranslucent = false
        UITabBar.appearance().barTintColor = UIColor(Color.pacificBlue)
    }
    
    // MARK: View
    var body: some View {
        TabView {
            SeafoodListView()
                .tabItem {
                    Image(systemName: "line.diagonal.arrow")
                    Text("Market")
                }.tag(0) // SeafoodMarketView
            ListingView()
                .tabItem {
                    Image(systemName: "list.bullet.rectangle")
                    Text("Listings")
                }.tag(1) // ListingView
            RequestView()
                .tabItem {
                    Image(systemName: "megaphone")
                    Text("Requests")
                }.tag(2) // RequestView
            MessengerView()
                .tabItem {
                    Image(systemName: "ellipsis.bubble")
                    Text("Messenger")
                }.tag(3) // MessengerView
            AccountView()
                .tabItem {
                    Image(systemName: "person")
                    Text("Account")
                }.tag(4) // AccountView
        } // TabView
        .accentColor(.white)
    }
}

// MARK: Preview
struct ContentView_Previews: PreviewProvider {
    static var previews: some View {
        ContentView()
    }
}

这是由于外观被破解...

init() {
//    UITabBar.appearance().isTranslucent = false   // remove this line !!!
    UITabBar.appearance().barTintColor = UIColor(Color.pacificBlue)
}

替代: 用配置的不透明背景替换整个外观

init() {

    let newAppearance = UITabBarAppearance()
    newAppearance.configureWithOpaqueBackground()
    newAppearance.backgroundColor = UIColor(Color.pacificBlue)
    UITabBar.appearance().standardAppearance = newAppearance

}