HomeiOS Developmentanimation - The right way to animate UITabBar backgroundColor in iOS 17

animation – The right way to animate UITabBar backgroundColor in iOS 17


I take advantage of transitionCoordinator of UINavigationController to vary background colour alongside pop / push animations inside popViewController / pushViewController features:

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

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

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

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

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

It labored high-quality till iOS 17.

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

Simulator the place every part works high-quality: iPhone 14 Professional (iOS 16.4)

enter image description here

Simulator the place it would not work: iPhone 14 Professional (iOS 17.0)

enter image description here

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments