简体   繁体   English

在iOS 7中,如何更改“更多”标签栏项目的颜色?

[英]In iOS 7, how do i change the color of the “More” tab bar item?

I'm able to set finished selected and unselected images for all the other tabs, but not for the "More" item which is special. 我可以为所有其他选项卡设置完成的选定和未选定的图像,但不能为特殊的“更多”项目设置。

截图

How can i do this? 我怎样才能做到这一点?

Here is the current code: 这是当前代码:

[[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 is white and delivered from our backend system. contrastColor颜色是白色,由我们的后端系统提供。

I don't know if this is an option for you or not, but you can try find a "More" image similar to the one you are using instead of using Apple's, which I am assuming you are using; 我不知道这是否适合您,但是您可以尝试找到一个与您使用的图像类似的“更多”图像,而不是使用苹果公司的图像(我假设您正在使用)。 if not just ignore me. 如果不是,那就不要理我。

Then just do this: 然后只需执行以下操作:

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

Have you tried with this? 你尝试过这个吗?

tabBarController.tabBar.barTintColor = yourBarColor;

tabBarController.tabBar.tintColor = yourSelectedIconAndTextColor;

And for different states: 对于不同的状态:

[[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];

Hope it helps! 希望能帮助到你!

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

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