Here is my view:
var body: some View {
TabView {
CountriesView(homeViewModel: homeViewModel)
.tabItem {
Label {
Text("Home")
} icon: {
Image(systemName: "house.fill")
}
}
.onAppear {
homeViewModel.getCountries()
}
SavedCountriesView(homeViewModel: homeViewModel)
.tabItem {
Label {
Text("Saved")
} icon: {
Image(systemName: "heart.fill")
}
}
}
.onAppear {
UITabBar.appearance().backgroundColor = UIColor.gray
UITabBar.appearance().unselectedItemTintColor = UIColor.white
UITabBar.appearance().barTintColor = UIColor(Color.black)
}
}
I have managed to change background and unselectedItem color but I can't change the color when item selected.
Here is what I've tried so far:
1-) Change UITabBar's barTintColor property.
2- Change the text and the image color from their properties. Adding foreground color to them does not effect this.
3-) Change TabView's accent color even tho it's deprecated on future versions. Also changing the accent color effects the whole page. I just want to change selected item colors.