如何在 iOS 17.0 中对 UITabBar backgroundColor 进行动画处理

How to animate UITabBar backgroundColor in iOS 17.0

提问人:Vladislav Markov 提问时间:9/26/2023 最后编辑:Vladislav Markov 更新时间:9/26/2023 访问量:45

问:

我使用 to 更改背景颜色以及内部的弹出/推送动画 / 功能:transitionCoordinatorUINavigationControllerpopViewControllerpushViewController

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
    // ...
}

它在 iOS 17 之前运行良好。

环境:macOS Ventura 13.6、Xcode 14.3.1 (14E300c)

一切正常的模拟器:iPhone 14 Pro (iOS 16.4)

enter image description here

模拟器不起作用:iPhone 14 Pro (iOS 17.0)

enter image description here

iOS 动画 UIKIT UITabBar

评论


答: 暂无答案