I'm developing an Apple TV OS app using SwiftUI. I'm encountering an issue with the color of the tab item. I want the color of the tab item to turn green when focused; for instance, when the tab item is selected, its background color should be green. Below is my current code, but it's not working. I've tried several other approaches, but none have worked.
struct ContentView: View {
@State private var selectedTab = 0
var body: some View {
ZStack(alignment: .topLeading){
TabView(selection: $selectedTab) {
HomeView()
.tabItem {
AppColors.gradientColor1
Label("Home", image: "home-dash")
}
.tag(0)
ProductsView()
.tabItem {
Label("Products", image: "open box-search")
}
.tag(1)
SearchView()
.tabItem {
Label("Search", image: "search")
}
.tag(2)
}
.accentColor(Color.green)
.background(.black)
Image("amazontabbarlogo")
}
}
}