I have UITabBarConroller subclass and custom items. Customization looks like this:
private func updateTabBar() {
guard let items = tabBar.items,
tabViewControllers.count == items.count else {
return
}
for (item, vc) in zip(items, tabViewControllers) {
// setting items title, image, selectedImage ...
item.setTitleTextAttributes(Self.normalAttributes, for: .normal)
item.badgeColor = .customColor
}
}
This works fine on iOS 14 and earlier. But not on iOS 15. I have found some information about scrollEdgeAppearance. This prevents black background. But setting colored text attributes and badge color is ignored.
The question is how to set custom text color and badge color on the UITabBarItem?
Finally, I did it. I was looking for
stackedLayoutAppearanceand its propertiesiconColorandbadgeBackgroundColor. Depending on your project you may need alsoinlineLayoutAppearanceorcompactInlineLayoutAppearance.And I use this static constant in my loop through all UITabBarItems: