1

hi since Xcode 13 the following Code does not work anymore, it still worked with Xcode 12

viewController.tabBarItem.badgeColor = color

In the Appearance settings, i can still set the badge color on app start with the following Code:

let tabBarAppearance = UITabBarAppearance()
tabBarAppearance.configureWithOpaqueBackground()
tabBarAppearance.backgroundColor = UIColor.tabBarBackground\

let tabBarItemAppearance = UITabBarItemAppearance()
tabBarItemAppearance.normal.titleTextAttributes = [.font: FontFamily.Arial.regular.font(size: 10.0)!]
tabBarItemAppearance.normal.badgeTextAttributes = [.foregroundColor: UIColor.white, .font: FontFamily.Arial.regular.font(size: 10.0)!]
tabBarItemAppearance.normal.badgeBackgroundColor = UIColor.black

tabBarAppearance.stackedLayoutAppearance = tabBarItemAppearance
UITabBar.appearance().standardAppearance = tabBarAppearance

if #available(iOS 15.0, *) {
    UITabBar.appearance().scrollEdgeAppearance = tabBarAppearance
}

In my situation, it is necessary to change the badgeColor depending on the ViewController state, so i need a code like this

viewController.tabBarItem.badgeColor = color
Phil Dukhov
  • 67,741
  • 15
  • 184
  • 220
BiNo
  • 11
  • 1

0 Answers0