更改iOS 7上的标签栏色调颜色

有没有办法将iOS 7上的标签栏的色调从默认的白色蓝色图标更改为另一种颜色色调与不同的颜色button?

尝试下面的内容:

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

要着色非活动button,将下面的代码放在VC的viewDidLoad

 UITabBarItem *tabBarItem = [yourTabBarController.tabBar.items objectAtIndex:0]; UIImage *unselectedImage = [UIImage imageNamed:@"icon-unselected"]; UIImage *selectedImage = [UIImage imageNamed:@"icon-selected"]; [tabBarItem setImage: [unselectedImage imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]]; [tabBarItem setSelectedImage: selectedImage]; 

你需要为所有的tabBarItems做到这一点,是的,我知道这是丑陋的,希望有更干净的方式来做到这一点。

迅速:

 UITabBar.appearance().tintColor = UIColor.red tabBarItem.image = UIImage(named: "unselected")?.withRenderingMode(.alwaysOriginal) tabBarItem.selectedImage = UIImage(named: "selected")?.withRenderingMode(.alwaysOriginal) 

有一个更简单的方法来做到这一点。

只需打开文件检查器并select“全局色调”。

您还可以在Interface Builder中设置应用程序的色调。 “文件”检查器的“界面生成器文档”部分中的“全局色调”菜单允许您打开“颜色”窗口或select特定的颜色。

另请参阅:

https://developer.apple.com/library/ios/documentation/userexperience/conceptual/TransitionGuide/AppearanceCustomization.html

iOS 7.1.1

如果有人需要使用全局设置色调颜色:

 [[UIView appearance] setTintColor:[UIColor whiteColor]]; 

didFinishLaunchingWithOptions中。

另外下面的代码将改变任何viewDidLoad方法中只有标签栏色调颜色:

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

在应用程序委托didFinishLaunchingWithOptions:

 window.tintColor = [UIColor purpleColor]; 

为应用程序全局设置色调颜色。

写在你的标签栏的视图控制器类:

 // Generate a black tab bar self.tabBarController.tabBar.barTintColor = [UIColor blackColor]; // Set the selected icons and text tint color self.tabBarController.tabBar.tintColor = [UIColor orangeColor]; 

界面生成器中的标签栏控制器的属性检查器 ”中,确保你的底部栏被设置为不透明标签栏:

选择不透明

现在转到您的AppDelegate.m文件。 找:

 - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions 

然后在花括号之间添加此代码以更改选项卡栏button和选项卡栏背景的颜色:

 ///----------------SET TAB BAR COLOR------------------------// //--------------FOR TAB BAR BUTTON COLOR---------------// [[UITabBar appearance] setTintColor:[UIColor greenColor]]; //-------------FOR TAB BAR BACKGROUND COLOR------------// [[UITabBar appearance] setBarTintColor:[UIColor whiteColor]]; 

终于为我工作的是:

 [self.tabBar setTintColor:[UIColor redColor]]; [self.tabBar setBarTintColor:[UIColor yellowColor]]; 

在尝试了所有build议的解决scheme后,我找不到任何有用的信息。

我终于尝试了以下内容:

 [self.tabBar setTintColor:[UIColor orangeColor]]; 

完美解决。

我只为每个TabBarItem提供了一个图像。 甚至不需要一个selectedImage。

我甚至用它在Child-ViewControllers中设置不同的TintColors:

 UIColor *theColorYouWish = ...; if ([[self.parentViewController class] isSubclassOfClass:[UITabBarController class]]){ UITabBarController *tbc = (UITabBarController *) self.parentViewController; [tbc.tabBar setTintColor:theColorYouWish]; } 

您可以将您的色调颜色和字体设置为setTitleTextattribute:

 UIFont *font= (kUIScreenHeight>KipadHeight)?[UIFont boldSystemFontOfSize:32.0f]:[UIFont boldSystemFontOfSize:16.0f]; NSDictionary *attributes = [NSDictionary dictionaryWithObjectsAndKeys:font, NSFontAttributeName, tintColorLight, NSForegroundColorAttributeName, nil]; [[UINavigationBar appearance] setTitleTextAttributes:attributes];