Reputation: 25751
I see by using the setTintColor on a tabBar I can change the selected item color.
How do I change the unselected tabBarItem color and text?
If I can't change it easily, what is the default gray color used (in RGB)?
Thanks.
Upvotes: 1
Views: 188
Reputation: 1987
Swift 5.1, iOS 13
if #available(iOS 13.0, *) {
let appearance = UITabBarAppearance()
appearance.stackedLayoutAppearance.selected.titleTextAttributes = [NSAttributedString.Key.foregroundColor: UIColor.white]
appearance.stackedLayoutAppearance.normal.titleTextAttributes = [NSAttributedString.Key.foregroundColor: UIColor.clear]
tabBar.standardAppearance = appearance
} else {
//Code for below iOS 13.0, which I'm currently looking into too.
}
Upvotes: 0
Reputation: 391
You can use images for tabBarItems.
To set unselected image use:
[tabBarItem setImage:(UIImage*)image]
To set selected image use:
[tabBarItem setSelectedImage:(UIImage*)image]
Text in tabBarItem is title of viewController thats connected to that tabBarItem.
You can find good icons for tabBar online, here's good one: https://icons8.com/
Upvotes: 1