UITabBarContoller 更改未选中项文本颜色
UITabBarContoller change not selected item text color
如何将此处未选中的项目更改为白色喜欢的项目?
这是我的属性:
您可以使用 UITabBarController 的子类以编程方式更改选项卡栏项目的文本颜色,并在子类的 viewDidLoad()
中,为选定状态和正常状态颜色添加以下代码。您也可以根据需要修改字体。
UITabBarItem.appearance().setTitleTextAttributes([NSAttributedStringKey.foregroundColor: UIColor.white, NSAttributedStringKey.font: selectedFont], for: .selected)
UITabBarItem.appearance().setTitleTextAttributes([NSAttributedStringKey.foregroundColor: UIColor.white, NSAttributedStringKey.font: normalFont], for: .normal)
如何将此处未选中的项目更改为白色喜欢的项目?
这是我的属性:
您可以使用 UITabBarController 的子类以编程方式更改选项卡栏项目的文本颜色,并在子类的 viewDidLoad()
中,为选定状态和正常状态颜色添加以下代码。您也可以根据需要修改字体。
UITabBarItem.appearance().setTitleTextAttributes([NSAttributedStringKey.foregroundColor: UIColor.white, NSAttributedStringKey.font: selectedFont], for: .selected)
UITabBarItem.appearance().setTitleTextAttributes([NSAttributedStringKey.foregroundColor: UIColor.white, NSAttributedStringKey.font: normalFont], for: .normal)