Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/102.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在iAbbar iOS中更改项目颜色_Ios_Objective C_Uitabbarcontroller - Fatal编程技术网

在iAbbar iOS中更改项目颜色

在iAbbar iOS中更改项目颜色,ios,objective-c,uitabbarcontroller,Ios,Objective C,Uitabbarcontroller,我的应用程序有一个选项卡栏,如下所示: 选项卡栏必须是绿色的,正如您所看到的,选项卡栏中项目的图标有点难以看到。如何更改此选项卡栏中图标的颜色?我必须使用标准选项卡栏。 谢谢试试这个 [[self tabBar] setSelectedImageTintColor:[UIColor greenColor]]; 还是这个 [UITabBarItem.appearance setTitleTextAttributes:@{ UITextAttributeTextColor : [UIC

我的应用程序有一个选项卡栏,如下所示:

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

试试这个

[[self tabBar] setSelectedImageTintColor:[UIColor greenColor]]; 
还是这个

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

[UITabBarItem.appearance setTitleTextAttributes:@{
    UITextAttributeTextColor : [UIColor purpleColor] }     forState:UIControlStateSelected];
    [UITabBarItem.appearance setTitleTextAttributes:@{NSForegroundColorAttributeName : [UIColor greenColor]} forState:UIControlStateNormal];    
   [UITabBarItem.appearance setTitleTextAttributes:@{NSForegroundColorAttributeName : [UIColor purpleColor]} forState:UIControlStateSelected];
还是这个

[[self tabBar] setTintColor:[UIColor redColor]];
还是这个

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

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

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

// set tabbar background image
[[UITabBar appearance] setBackgroundImage:[UIImage imageNamed:@"tabbar_bg"]];
// remove shadow image of tabbar
[[UITabBar appearance] setShadowImage:[[UIImage alloc]init]];

您可以使用以下代码来使用图标图像,而不是使用图标

UITabBar *tabBar = tabBarController.tabBar;
UITabBarItem *tabBarItem1 = [tabBar.items objectAtIndex:0];

tabBarItem1.selectedImage = [[UIImage imageNamed:@"selectedImage.png"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal ];
tabBarItem1.image = [[UIImage imageNamed:@"unselectedImage.png"]imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal ];
tabBarItem1.imageInsets= UIEdgeInsetsMake(6, 0, -6, 0);

我建议,将UITabbar的背景颜色改为一些较深的颜色,而不是绿色。对于未选中的选项卡,只需保留默认的灰色(苹果遮罩为灰色)。使用“下剪”设置选定选项卡遮罩颜色

[[UITabBar外观]setTintColor:[UIColor REDCLOR]]

这将避免最终用户混淆选项卡是处于选中状态还是处于未选中状态。

请参阅以下问题