【问题标题】:In iOS 7, how do i change the color of the "More" tab bar item?在 iOS 7 中,如何更改“更多”标签栏项目的颜色?
【发布时间】:2013-10-23 11:38:50
【问题描述】:

我可以为所有其他选项卡设置完成的选定和未选定图像,但不能为特殊的“更多”项目设置。

我该怎么做?

这是当前代码:

[[UITabBar appearance] setTintColor:contrastColor];
[[UITabBarItem appearance] setTitleTextAttributes:@{UITextAttributeTextColor: contrastColor, UITextAttributeTextShadowOffset: [NSValue valueWithUIOffset:UIOffsetMake(0, 0)]} forState:UIControlStateSelected];
[[UITabBarItem appearance] setTitleTextAttributes:@{UITextAttributeTextColor: contrastColor, UITextAttributeTextShadowOffset: [NSValue valueWithUIOffset:UIOffsetMake(0, 0)]} forState:UIControlStateNormal];

contrastColor 是白色的,由我们的后端系统提供。

【问题讨论】:

  • 关闭投票作为离题?你在开玩笑吗?
  • 亲爱的朋友,您无法使用更多按钮进行任何更改,因为当您的 tabBar 有 5 个或更多 5 个 tanItem 时,它是内置的。所以最好的方法是停止与它战斗..: )
  • 嗯,您可以更改文本颜色,并且可以修改 tableview 控制器和导航栏的外观,所以必须对图标进行修改!
  • 好吧.. 但几个月前我试过了.. 你也可以在 goole 上搜索.. 可能你会找到与我的评论相同的答案:( Al D bSt :)

标签: ios ios7 toolbar uiappearance


【解决方案1】:

我不知道这是否适合您,但您可以尝试找到与您正在使用的图片相似的“更多”图片,而不是使用 Apple 的图片,我假设您正在使用它;如果不只是不理我。

那么就这样做吧:

UITabBarItem *tabBarItem4 = [[tabViewController.tabBar items] objectAtIndex:3];
[tabBarItem4 setFinishedSelectedImage:[UIImage imageNamed:@"tabbar-more-selected"] withFinishedUnselectedImage:[UIImage imageNamed:@"tabbar-more-normal"]];

【讨论】:

  • 好的,所以通过一个小的修改 (objectAtIndex:4) 这实际上是有效的。我确定我之前尝试过但没有成功,但这次成功了。非常感谢!
  • 另外,设置所选图像没有任何效果,但我对填充白色的图像感到满意!
  • 顺便说一句,知道如何在 iOS 6 中也能做到这一点吗?我创建了两个自定义选择和未选择的更多图标。它们在 iOS 7 中运行良好,但 iOS 6 仍然是灰色和蓝色。
  • @Maciej Swic:你是什么意思选择的图像没有效果?您对选定的图像和未选定的图像使用两个不同的文件来作为您需要的方式。此外,如果您想让这在 iOS6 中看起来相似,您有几个选择。
  • 这是我最想不到的两个。 1.) 完全定制!含义标签栏背景和标签栏有自己的图像。这是一个关于 iOS 6 自定义的非常好的教程:raywenderlich.com/21703/user-interface-customization-in-ios-6 2.) 使用这里找到的 UI7Kit:github.com/youknowone/UI7Kit 我从未使用过它,但听说过它的好消息。希望这可以帮助。祝你好运,编码愉快。
【解决方案2】:

你试过了吗?

tabBarController.tabBar.barTintColor = yourBarColor;

tabBarController.tabBar.tintColor = yourSelectedIconAndTextColor;

对于不同的状态:

[[UITabBarItem appearance] setTitleTextAttributes:@{NSFontAttributeName:[UIFont fontWithName:yourFontName size:yourFontSize], NSForegroundColorAttributeName: yourSelectedIconAndTextColor} forState:UIControlStateSelected];

[[UITabBarItem appearance] setTitleTextAttributes:@{NSFontAttributeName : [UIFont fontWithName:yourFontName size:yourFontSize], NSForegroundColorAttributeName:[UIColor defaultColor]} forState:UIControlStateNormal];

希望对你有帮助!

【讨论】:

  • 是的,这就是我设置当前白色和紫色外观的方式。不幸的是,它似乎不会影响“更多”项目的未选中状态。很抱歉在问题中没有更清楚地说明这一点。
  • 你设置了self.tabBarController.tabBar.translucent = false;吗?
  • 我刚才试过了,但没有任何区别。除了稍微移动图像,因为它会影响自动布局。
  • 我不知道,如果你看过这个页面,可能会有用:stackoverflow.com/questions/19013967/…
猜你喜欢
  • 1970-01-01
  • 2013-09-18
  • 2014-09-12
  • 2013-11-17
  • 2014-10-03
  • 2012-02-27
  • 2013-09-12
  • 2013-06-11
  • 2015-09-15
相关资源
最近更新 更多