I've been trying for several hours to change the color of the Navigation Bar in my app... It's a little better than before, because I added the "isTranslucent" parameter, so now the Navigation Bar is gray (before this, it was completely white), but I still can't set it to the same color as the sidebar, and especially with the same height: the height becomes the same only when I press an element in the sidebar...
Here's what happens before I tap on a sidebar element:
And here after I tapped it:
Here's the code:
import SwiftUI
let furl = URL(fileURLWithPath: "path")
struct ContentView: View {
@State private var selected = 0
@State private var isActive = false
var body: some View {
TabView(selection: $selected) {
NavigationView {
HomeView()
}
.navigationViewStyle(StackNavigationViewStyle())
.tabItem {
Image(systemName: (selected == 0 ? "house.fill" : "house"))
Text("Home")
}.tag(0)
NavigationView {
CategoryView(dm: DownloadManager())
}
.navigationViewStyle(DoubleColumnNavigationViewStyle())
.tabItem {
Image(systemName: (selected == 1 ? "text.justify" : "text.justify"))
Text("Categorie")
}.tag(1)
NavigationView {
GalleryView(dm: DownloadManager())
}
.navigationViewStyle(DoubleColumnNavigationViewStyle())
.tabItem {
Image(systemName: (selected == 2 ? "photo.fill" : "photo"))
Text("Galleria")
}.tag(2)
NavigationView {
SearchView()
}
.navigationViewStyle(DoubleColumnNavigationViewStyle())
.tabItem {
Image(systemName: (selected == 3 ? "magnifyingglass" : "magnifyingglass"))
Text("Ricerca")
}.tag(3)
NavigationView {
FavoritesView()
}
.navigationViewStyle(DoubleColumnNavigationViewStyle())
.tabItem {
Image(systemName: (selected == 4 ? "star.fill" : "star"))
Text("Preferiti")
}.tag(4)
}
.accentColor(.white)
.onAppear() {
UINavigationBar.appearance().isTranslucent = false
UINavigationBar.appearance().barTintColor = UIColor(red: 112.0/255.0, green: 90.0/255.0, blue: 143.0/255.0, alpha: 1.0)
UINavigationBar.appearance().titleTextAttributes = [NSAttributedString.Key.foregroundColor: UIColor.white]
UITabBar.appearance().barTintColor = UIColor(red: 112.0/255.0, green: 90.0/255.0, blue: 143.0/255.0, alpha: 1.0)
}
}
}
struct ContentView_Previews: PreviewProvider {
static var previews: some View {
ContentView()
}
}
Please help, I'm going crazy from trying! Thank you!