[英]In iOS 7, how do i change the color of the “More” tab bar item?
我可以为所有其他选项卡设置完成的选定和未选定的图像,但不能为特殊的“更多”项目设置。
我怎样才能做到这一点?
这是当前代码:
[[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
颜色是白色,由我们的后端系统提供。
我不知道这是否适合您,但是您可以尝试找到一个与您使用的图像类似的“更多”图像,而不是使用苹果公司的图像(我假设您正在使用)。 如果不是,那就不要理我。
然后只需执行以下操作:
UITabBarItem *tabBarItem4 = [[tabViewController.tabBar items] objectAtIndex:3];
[tabBarItem4 setFinishedSelectedImage:[UIImage imageNamed:@"tabbar-more-selected"] withFinishedUnselectedImage:[UIImage imageNamed:@"tabbar-more-normal"]];
你尝试过这个吗?
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];
希望能帮助到你!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.