Up to Xcode 15 and iOS 17, it was easy to change the tab bar item badge color in UIKit using this kind of code:
private func setupBadgeColors(item: UITabBarItem?, backgroundColor: UIColor, textColor: UIColor) {
guard let item
else { return }
item.badgeColor = backgroundColor
item.setBadgeTextAttributes([.foregroundColor: textColor], for: .normal)
}
Unfortunately this is not effective anymore with Xcode 16 and iOS 18.
I can change the aspect of all the badges of the tab bar, using the badgeBackgroundColor
and badgeTextAttribute
of a UITabBarItemStateAppearance
within a UITabBarItemApperance
of a UITabBarAppearance
.
I can even customize the appearance of all the badges according to the selected item by updating the specific UITabBarAppearance
of each item.
Unfortunately I wish to find a way to customize the badge of each item specifically.
Thank you for your help.