简体   繁体   English

iOS-如何更改选项卡栏中图标的颜色moreViewController

[英]iOS - How to change color of icons in tab bar moreViewController

I want to change color of icons (and probably badge) in moreNavigationController from gray to something else. 我想将moreNavigationController的图标(可能是徽章)的moreNavigationController从灰色更改为其他颜色。

I've read and successfully changed color of background and text. 我已阅读并成功更改了背景和文本的颜色。 I did this by "replacing" data source of moreViewController (described eg here Customizing the More menu on a Tab bar ). 我是通过“替换” moreViewController数据源来moreViewController (例如,在此处定制“标签”栏上的“更多”菜单 )。 But updating icons (also textLabel value) here makes no effect. 但是,此处更新图标(以及textLabel值)无效。 Is it possible to change this gray color to white (or anything else)? 是否可以将此灰色更改为白色(或其他颜色)? Or I have to implement my own tabBarController ? 还是我必须实现自己的tabBarController (any good tutorials?) (有什么好的教程吗?)

PS. PS。 I know how to change icons on tab bar itself, the question is how to do this in moreViewController ? 我知道如何更改标签栏本身的图标,问题是如何在moreViewController执行此moreViewController

Thanks! 谢谢! Piotr 皮特

In case it is still relevant to anyone. 万一它仍然与任何人有关。 You can change icon colors displayed in a tableView of moreViewController: 您可以更改moreViewController的tableView中显示的图标颜色:

self.tabBarController?.moreNavigationController.topViewController?.view.tintColor = UIColor.redColor()

Changing a title is like so: 更改标题就像这样:

self.tabBarController?.moreNavigationController.navigationBar.topItem?.title = "MyString"

Changing Edit button: 更改编辑按钮:

self.tabBarController?.moreNavigationController.navigationBar.tintColor = UIColor.redColor()

You can do this using the appearance proxy, new in iOS 5. In your app delegate's didFinishLaunching method: 您可以使用iOS 5中新增的外观代理来执行此操作。在应用程序委托的didFinishLaunching方法中:

[[UITabBar appearance] setSelectedImageTintColor:[UIColor redColor]];
In iOS 7 use:

[[UITabBar appearance] setTintColor:[UIColor redColor]];

See the UITabBar class reference for more details. 有关更多详细信息,请参见UITabBar类参考。

Ok, from long research on the web and answers in this thread, it seems that it is not possible on iOS7 to change color of the icons (gray color) displayed in moreViewController of UITabBarController . 好的,从对网络的长期研究和对该线程的答案来看,似乎无法在iOS7上更改UITabBarController moreViewController中显示的图标的颜色(灰色)。 The best solution for customizable tab bar is to implement it (or use some library). 可自定义标签栏的最佳解决方案是实施它(或使用某些库)。

Thanks! 谢谢!

You can change the color, just subclass the tab bar controller and in it's view did load add the below code 您可以更改颜色,只需将标签栏控制器子类化,并在其视图中加载以下代码即可

  override func viewDidLoad() {
    super.viewDidLoad()
    var view = self.moreNavigationController.topViewController.view as UITableView
    view.tintColor = Utilities.mainColor()
    view.separatorStyle = .None
  }

For more you can see my question here : Change tint color of tabbar edit view controller 有关更多信息,您可以在这里看到我的问题: 更改标签栏的色调颜色编辑视图控制器

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM