[ad_1]
In my app I’ve 2 tabs.
First tab view has white background.
Second tabView has black background.
Due to that I want to change tabbar model relying on what TabBarItem chosen
When tab1 is chosen, I would love tab bar icons coloration to be:
chosen - black, unselected - gray
When tab2 is chosen, I want to change colours to:
chosen - white, unselected - gray
I will change icon coloration with accentColor property like that:
TabView {
FirstTabView()
.tabItem {
Picture("tab1").renderingMode(.template)
}
SecondTabView()
.tabItem {
Picture("tab2").renderingMode(.template)
}
}.accentColor(.white)
However tips on how to change icon coloration when consumer click on on second tab ?
I attempted one thing like that:
@State non-public var choice = 0
TabView(choice: $choice) {
FirstTabView()
.tabItem {
Picture("tab1").renderingMode(.template)
}
SecondTabView()
.tabItem {
Picture("tab2").renderingMode(.template)
}
}.accentColor(choice == 0 ? .black : .white)
Nevertheless it would not work
[ad_2]
