🤔

iPadOS18以上の場合、タブのバッジがカスタマイズできない?

2025/02/11に公開

iPadOS18からタブが上部に移動しましたが、その影響かタブのバッジの色の変更などが効かなそう。

private func setupTabAppearance() {
    let tabBarAppearance = UITabBarAppearance()
    let tabBarItemAppearance = UITabBarItemAppearance()
    tabBarItemAppearance.normal.titleTextAttributes = [.foregroundColor: UIColor.gray]
    tabBarItemAppearance.normal.badgeBackgroundColor = .clear
    tabBarItemAppearance.normal.badgeTextAttributes = [.foregroundColor: UIColor.blue]
    tabBarAppearance.stackedLayoutAppearance = tabBarItemAppearance
    tabBarAppearance.inlineLayoutAppearance = tabBarItemAppearance
    tabBarAppearance.compactInlineLayoutAppearance = tabBarItemAppearance
    tabBarAppearance.backgroundImageContentMode = .scaleAspectFit
    tabBarAppearance.shadowImage = nil
    tabBar.standardAppearance = tabBarAppearance
    UITabBar.appearance().scrollEdgeAppearance = tabBarAppearance
}

badgeValueには ⚫︎ を指定

firstVC.tabBarItem.badgeValue = "⚫︎"

バッジを小さくするためのカスタマイズを入れていたのですが、そもそもbadgeTextAttributesに指定しているforegroundColorも効かないみたいでした。

iPhone iPad

フォーラムで質問してる方はいますが、華麗にスルーされていますね...
https://developer.apple.com/forums/thread/761056?answerId=803715022#803715022

Discussion