.tint
and .accentColor
affect WAY more than just the tab bar and seeps into toggles, navigation bar button items, sliders, etc., and it seems like a giant pain to set every single component accent individually to avoid this. How can I change the selected item color without affecting any other components?
I’ve tried setting .foregroundColor
/.foregroundStyle
on the tab item views (doesn’t work).
I also tried setting this in the init with no appreciable effect:
init {
let tabBarAppearance = UITabBarAppearance()
tabBarAppearance.configureWithDefaultBackground()
tabBarAppearance.stackedLayoutAppearance.selected.iconColor = UIColor.red
tabBarAppearance.stackedLayoutAppearance.selected.titleTextAttributes = [.foregroundColor: UIColor.red]
tabBarAppearance.stackedLayoutAppearance.normal.iconColor = UIColor.lightGray
tabBarAppearance.stackedLayoutAppearance.normal.titleTextAttributes = [.foregroundColor: UIColor.lightGray]
UITabBar.appearance().standardAppearance = tabBarAppearance
UITabBar.appearance().scrollEdgeAppearance = tabBarAppearance
}
I’d prefer not using a custom made tab bar in an overlay if possible. Is there any way to achieve this in the native tab bar without changing the colors of any other component?