Search code examples
iosswiftuitabbarios13uitabbaritem

ios13 - UITabBar tintColor for unSelectedItem not working


In Xcode 10 unselectedItemTintColor property working properly but after Xcode 11 with ios 13 UITabbar unselectedItemTintColor property not working.

override func viewDidLoad() {
    super.viewDidLoad()

    myTabbar.unselectedItemTintColor = .red
}

Solution

  • iOS 13 with Xcode 11

    if #available(iOS 13, *) {
         let appearance = UITabBarAppearance()
         appearance.stackedLayoutAppearance.normal.titleTextAttributes = [NSAttributedString.Key.foregroundColor: UIColor.black]
         appearance.stackedLayoutAppearance.selected.titleTextAttributes = [NSAttributedString.Key.foregroundColor: UIColor.red]
         appearance.stackedLayoutAppearance.normal.iconColor = UIColor.black
         appearance.stackedLayoutAppearance.selected.iconColor = UIColor.red
         myTabbar.standardAppearance = appearance
    }