更改 uitabbar 默认色调

change the uitabbar default color tint

我想在未选中时更改 uitabbar 上的默认灰色色调。我的问题是我尝试了以下代码,但它第一次只显示默认的灰色,之后它变为 mu 所需的白色色调,这实际上是我的图像颜色。

在 didFinishLaunchingWithOptions

[[tabBarController.tabBar.items objectAtIndex:0] setFinishedSelectedImage:nil withFinishedUnselectedImage:[UIImage imageNamed:@"mylib"]];
[[tabBarController.tabBar.items objectAtIndex:1] setFinishedSelectedImage:nil withFinishedUnselectedImage:[UIImage imageNamed:@"explore"]];
[[tabBarController.tabBar.items objectAtIndex:2] setFinishedSelectedImage:nil withFinishedUnselectedImage:[UIImage imageNamed:@"radio"]];
[[tabBarController.tabBar.items objectAtIndex:3] setFinishedSelectedImage:nil withFinishedUnselectedImage:[UIImage imageNamed:@"search"]];
[[tabBarController.tabBar.items objectAtIndex:4] setFinishedSelectedImage:nil withFinishedUnselectedImage:[UIImage imageNamed:@"people"]];

[[UITabBarItem appearance] setTitleTextAttributes:@{ NSForegroundColorAttributeName : [UIColor whiteColor] }forState:UIControlStateNormal];
    [[UITabBarItem appearance] setTitleTextAttributes:@{ NSForegroundColorAttributeName : [UIColor colorWithRed:(191/255.0) green:(2/255.0) blue:(6/255.0) alpha:1] }forState:UIControlStateSelected];
    [[UITabBar appearance] setTintColor:[UIColor colorWithRed:(191/255.0) green:(2/255.0) blue:(6/255.0) alpha:1]];

请帮助我摆脱这个默认的灰色,并希望它变成白色。

您可以继承 UITabBar 及其 viewDidLoad 方法:

- (void)viewDidLoad {
   [super viewDidLoad];
   //Do your logic here...
}