ios - 在 UITabBar iOS 中更改项目颜色

标签 ios objective-c uitabbarcontroller

我的应用程序有一个标签栏,如下所示:

enter image description here

Tab Bar 必须是绿色的,正如您所看到的,Tab Bar 中项目的图标有点难看。如何更改此选项卡栏中图标的颜色?我必须使用标准的标签栏。 谢谢

最佳答案

试试这个

[[self tabBar] setSelectedImageTintColor:[UIColor greenColor]]; 

或者这个

[UITabBarItem.appearance setTitleTextAttributes:@{
    UITextAttributeTextColor : [UIColor greenColor] } forState:UIControlStateNormal];

[UITabBarItem.appearance setTitleTextAttributes:@{
    UITextAttributeTextColor : [UIColor purpleColor] }     forState:UIControlStateSelected];

或者这个

[[self tabBar] setTintColor:[UIColor redColor]];

或者这个

    [UITabBarItem.appearance setTitleTextAttributes:@{NSForegroundColorAttributeName : [UIColor greenColor]} forState:UIControlStateNormal];    
   [UITabBarItem.appearance setTitleTextAttributes:@{NSForegroundColorAttributeName : [UIColor purpleColor]} forState:UIControlStateSelected];

关于ios - 在 UITabBar iOS 中更改项目颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28294564/

相关文章:

iphone - iOS 是否允许开发人员这样做?

ios - 两个NSData对象-base64编码为1个“包”

objective-c - 了解第一响应者的系统逻辑

objective-c - 在 UITextView 上的 NSAttributedString 上设置字体忽略行距

ios - 标签栏 Controller 需要点击2次返回主视图

ios - 如何在 RootView ChildViewControllers 中隐藏 TabBar

ios - startMonitoring 不适用于 "WhenInUseAuthorization"权限

objective-c - 协作 Objective C 和 monotuch

ios - 在 Swift 中对 UITabBarController 进行 segue 后如何摆脱 UINavigationController?

ios - Titanium Appcelerator 无法向指定用户发送推送通知