TabBarItemは、テキストの色の失敗を変更します

  • 最近の研究スウィフトは、プロジェクトから、見つからtabBarItem選択されていないテキストの色は、作業、システムのデフォルトは灰色ですしません
UITabBarItem.appearance().setTitleTextAttributes([NSAttributedString.Key.foregroundColor: UIColor.green], for: .selected)
UITabBarItem.appearance().setTitleTextAttributes([NSAttributedString.Key.foregroundColor: UIColor.red], for: .normal)

次の質問に対し、特定のiOS質問13ではない、彼が認定を行っていないiOS13の問題であると言われました。

ソリューション

13歳未満のiOSのUITabBarItem.appearance().setTitleTextAttributes([NSAttributedString.Key.foregroundColor: UIColor.red], for: .normal)プロパティはすでに仕事、Appleはこのを通じて、いくつかのブラインドを出していない、それは不快ではない通常の状態に設定されています

tabBar.tintColor = UIColor.blue
// 通过UITabBar.appearance() 点不出unselectedItemTintColor属性, 可以直接硬敲
// UITabBar.appearance().unselectedItemTintColor = UIColor.red
tabBar.unselectedItemTintColor = UIColor.red

若しくは

UITabBarItem.appearance().setTitleTextAttributes([NSAttributedString.Key.foregroundColor: UIColor.green], for: .selected)
tabBar.unselectedItemTintColor = UIColor.red

おすすめ

転載: www.cnblogs.com/gchlcc/p/12564110.html