如何更改标签栏项目文本颜色 [英] How to change tab bar item text color

查看:111
本文介绍了如何更改标签栏项目文本颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

怎么能我在tabbar中更改更多..文本的颜色以匹配其图标颜色。 (现在在标签栏中选择了Performance)

How can I change the color of "More.." text in tabbar to match with its icon color. (Right now Performance is selected in the tab bar)

我试图设置TitleTextAttributes。

I tried to set TitleTextAttributes.

[moreItem setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:[UIFont fontWithName:@"HelveticaLTStd-Roman" size:10.0f], NSFontAttributeName,  [UIColor yellowColor],NSForegroundColorAttributeName , nil]

但文本颜色始终设置为黄色。即使选择了该项目。喜欢这个

But it the text color is always set to yellow. even when the item is selected. Like this

我在选择时尝试设置为白色,未选中时应与图标颜色匹配。
谢谢..
任何建议都会非常有用。

I am trying set to white when selected and when unselected it should match with icon color. Thanks.. Any suggestions will be really helpful.

推荐答案

我找到了自己的答案题。

I found the answer for my own question.

我们可以为两种不同的状态设置 perforamceItem setTitleTextAttributes:

We can set perforamceItem setTitleTextAttributes: for two different states.


  • forState:UIControlStateNormal

  • forState:UIControlStateHighlighted

  • forState:UIControlStateNormal
  • forState:UIControlStateHighlighted

我添加了以下代码

 [performanceItem setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:[UIFont fontWithName:@"HelveticaLTStd-Roman" size:10.0f], NSFontAttributeName,  [UIColor yellowColor], NSForegroundColorAttributeName,nil] forState:UIControlStateNormal];

[performanceItem setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:[UIFont fontWithName:@"HelveticaLTStd-Roman" size:10.0f], NSFontAttributeName,  [UIColor whiteColor], NSForegroundColorAttributeName,nil] forState:UIControlStateHighlighted];

我需要用我的图标颜色替换黄色。这就是他们现在的样子。

I need to replace the yellow color with the color of my ICONS. This is how they are looking now.

这篇关于如何更改标签栏项目文本颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆