Using SwiftUI, I have several NavigationViews nested inside a TabBar. The reason for this is that I would like to change the title of each NavigationView to reflect the selected tab, and I can't find another way to do this. Also, it is very important to my client that the background color of the UITabBar be solid white. For this reason I set UITabBar.appearance().isTranslucent = false, otherwise it appears grey. However, as soon as I do this, I see a strange grey line above the UITabBar. How can I get rid of this?
struct ContentView: View {
init() {
UITabBar.appearance().backgroundColor = UIColor.white
UITabBar.appearance().isTranslucent = false
}
var body: some View {
TabView {
NavigationView {
Text("First tab")
.padding(10)
.background(Color.white)
.navigationBarTitle(Text("First tab"), displayMode: .inline)
}
.tabItem {
Text("First tab")
}
NavigationView {
Text("Second tab")
.padding(10)
.background(Color.white)
.navigationBarTitle(Text("Second tab"), displayMode: .inline)
}
.tabItem {
Text("Second tab")
}
}
}
}

