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.
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/
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.
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.