
我在标签栏里有四件东西。
1>观察。(黑色)
2>点播。(黑色)
3>搜索。(黑色)
4>设置(我的颜色)
如何更改标签栏中项目文本的颜色以与其图标颜色匹配。(现在,在选项卡栏中选择了性能)
在这里输入图像描述
如何将选项卡中"1,2,3“文本的颜色更改为与其图标颜色匹配。(现在,在选项卡栏中选择了性能)
我试着设置TitleTextAttributes。
UITabBarItem.appearance().setTitleTextAttributes([NSForegroundColorAttributeName: UIColor(red: 255.0/255.0, green: 255.0/255.0, blue: 255.0/255.0, alpha: 1.0),NSFontAttributeName: UIFont(name: "SFUIDisplay-Regular", size: 36.0)!], forState:UIControlState.Normal)
UITabBarItem.appearance().setTitleTextAttributes([NSForegroundColorAttributeName: UIColor(red: 22.0/255.0, green: 209.0/255.0, blue: 237.0/255.0, alpha: 1.0),NSFontAttributeName: UIFont(name: "SFUIDisplay-Regular", size: 36.0)!], forState:UIControlState.Focused)但我想喜欢它。

这个问题出现在tvOS9.1中。
发布于 2016-02-11 23:17:26
我不确定我是否理解你的问题,但在开发苹果电视应用程序时,我也面临着一些类似的问题。
我想要做的是更改选项卡栏项的字体颜色。
这就是我结束了做的事。首先,我创建了一个UITabBarController子类,并将它放在故事板上的控制器上。然后我在-(void)viewDidLoad中添加了这段代码
for(UITabBarItem * item in self.tabBar.items) {
[item setTitleTextAttributes:@{NSForegroundColorAttributeName : [UIColor darkGrayColor]} forState:UIControlStateNormal];
[item setTitleTextAttributes:@{NSForegroundColorAttributeName : [UIColor blueColor]} forState:UIControlStateFocused];
}一切都很顺利。
希望能帮上忙!
发布于 2019-03-29 20:49:40
快速5解决方案:
override func viewDidLoad() {
super.viewDidLoad()
for item in (self.tabBarController?.tabBar.items)! {
item.setTitleTextAttributes([NSAttributedString.Key.foregroundColor: UIColor.white], for: .focused)
item.setTitleTextAttributes([NSAttributedString.Key.foregroundColor: UIColor.lightGray], for: .normal)
}
}https://stackoverflow.com/questions/34433009
复制相似问题