iOS 15 UITabBarController's tabBar background color turns black

tabBar.barTintColor can't be changed in iOS 15 beta 4.

Background. We have an app in App Store and each year before the new iOS major version releases we download the iOS beta and test our app to fix the issues beforehand.

Our problem. This year when testing in iOS 15 beta 4 we found the UITabBarController's tabBar background color turns black and makes the item (both icon and title) hard to read. In our code we had self.tabBar.barTintColor = .white and this line of code doesn't work in iOS 15.

Our attempts. I search online and found a similar, not exactly the same, issue reported, https://developer.apple.com/forums/thread/682420. And I tried standardAppearance but this is not the solution since with appearance I can't change tabBar.tintColor.


I had the same issue and found the same link that is in your question. I used the same approach for the tab bar.

This is the code i am using and it works perfectly.

if #available(iOS 15.0, *) {
   let appearance = UITabBarAppearance()
   appearance.configureWithOpaqueBackground()
   appearance.backgroundColor = customColor
   
   self.tabController.tabBar.standardAppearance = appearance
   self.tabController.tabBar.scrollEdgeAppearance = view.standardAppearance
}

Similar to an answer above but with a fix for view not being recognised if you are using custom classes:

if #available(iOS 15.0, *) {
    let appearance = UITabBarAppearance()
    appearance.configureWithOpaqueBackground()
    appearance.backgroundColor = .white
    tabBar.standardAppearance = appearance
    tabBar.scrollEdgeAppearance = tabBar.standardAppearance
}

Create a UITabBarAppearance like this to maintain the same visual behavior as previous iOS versions:

@available(iOS 15.0, *)
private func updateTabBarAppearance() {
    let tabBarAppearance: UITabBarAppearance = UITabBarAppearance()
    tabBarAppearance.configureWithOpaqueBackground()
    
    let barTintColor: UIColor = .white
    tabBarAppearance.backgroundColor = barTintColor
    
    updateTabBarItemAppearance(appearance: tabBarAppearance.compactInlineLayoutAppearance)
    updateTabBarItemAppearance(appearance: tabBarAppearance.inlineLayoutAppearance)
    updateTabBarItemAppearance(appearance: tabBarAppearance.stackedLayoutAppearance)
    
    self.tabBar.standardAppearance = tabBarAppearance
    self.tabBar.scrollEdgeAppearance = tabBarAppearance
}

@available(iOS 13.0, *)
private func updateTabBarItemAppearance(appearance: UITabBarItemAppearance) {
    let tintColor: UIColor = .red
    let unselectedItemTintColor: UIColor = .green
    
    appearance.selected.iconColor = tintColor
    appearance.normal.iconColor = unselectedItemTintColor
}