【问题标题】:How to change the [more] button text color in UITabBar?如何更改UITabBar中的[更多]按钮文本颜色?
【发布时间】:2012-12-10 15:23:10
【问题描述】:

我按照answer 将栏项目文本颜色更改为白色,但我有 6 个标签栏项目,我无法获取系统按钮 [更多] 项目并更改文本颜色。

如何将此 [more] 按钮文本颜色更改为白色? 谢谢。

我的代码:

for (UITabBarItem* item in self.tabBar.items)
{
    NSLog(@"title:%@",item.title); // only get my items
    [item setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:
                                  [UIFont fontWithName:@"AmericanTypewriter" size:11.0f], UITextAttributeFont,
                                  [UIColor whiteColor], UITextAttributeTextColor,
                                  [UIColor clearColor], UITextAttributeTextShadowColor,
                                  [NSValue valueWithUIOffset:UIOffsetMake(0.0f, 1.0f)], UITextAttributeTextShadowOffset,
                                  nil] forState:UIControlStateNormal];
}

【问题讨论】:

  • 你是用[UITabBarItem外观]还是smth。还有吗?
  • 是的,tabBar.items我只得到我的物品,无法得到系统moretabbaritem,所以我不能在上面使用setTitleTextAttributes
  • @jaydee3,对不起,我明白了,它工作!非常感谢!

标签: objective-c uitabbar uitabbaritem


【解决方案1】:

你试过了吗,它对我有用:

[[UITabBarItem appearance] setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:
                                             [UIFont fontWithName:@"AmericanTypewriter" size:20.0f], UITextAttributeFont,
                                             [UIColor yellowColor], UITextAttributeTextColor,
                                             [UIColor redColor], UITextAttributeTextShadowColor,
                                             [NSValue valueWithUIOffset:UIOffsetMake(0.0f, 1.0f)], UITextAttributeTextShadowOffset,
                                             nil] forState:UIControlStateNormal];

或者将 self.myTabBar 替换为 [UITabBarItem 外观]

【讨论】:

  • 好人,顺便说一句,我对此还有另一个问题,如何将图标颜色更改为白色?现在标签栏的颜色是蓝色的,但我想要图像图标的颜色不同。标签栏可以做到吗?
猜你喜欢
  • 2012-06-25
  • 1970-01-01
  • 2021-11-12
  • 1970-01-01
  • 1970-01-01
  • 2013-06-05
  • 2019-02-14
  • 2017-04-10
  • 2011-03-14
相关资源
最近更新 更多