How to animate UITabBar backgroundColor in iOS 17.0

58 Views Asked by At

I use transitionCoordinator of UINavigationController to change background color alongside pop / push animations inside popViewController / pushViewController functions:

let tabBar: UITabBar = ... // UITabBar of UITabBarController

transitionCoordinator.animate { [weak self] _ in
    tabBar.isTranslucent = true
    tabBar.isOpaque = true
    tabBar.unselectedItemTintColor = colors.unselectedItemTint
    tabBar.tintColor = colors.tint
    tabBar.barTintColor = colors.background

    let tabBarAppearance = UITabBarAppearance()
    tabBarAppearance.configureWithOpaqueBackground()
    tabBarAppearance.backgroundColor = colors.background // some UIColor
    tabBarAppearance.shadowColor = currentTabType == .shortVideo ? .clear : colors.border
    tabBar.standardAppearance = tabBarAppearance

    if #available(iOS 15, *) {
      tabBar.scrollEdgeAppearance = tabBarAppearance
    }

    tabBar.layoutIfNeeded()
} completion: { [weak self] context in
    // ...
}

It worked fine until iOS 17.

Environment: macOS Ventura 13.6, Xcode 14.3.1 (14E300c)

Simulator where everything works fine: iPhone 14 Pro (iOS 16.4)

enter image description here

Simulator where it doesn't work: iPhone 14 Pro (iOS 17.0)

enter image description here

0

There are 0 best solutions below