Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change tab bar tint color on iOS 7

Is there a way to change the tint of a tab bar on iOS 7 from the default white with blue icons to another color tint with different color buttons?

like image 318
Jake Chasan Avatar asked Sep 13 '13 20:09

Jake Chasan


People also ask

What is tint color in iOS?

What is tintColor? tintColor is a variable in UIView that returns a color. The color returned is the first non-default value in the receiver's superview chain (starting with itself). If no non-default value is found, a system-defined color is returned (the shiny blue you always see).


2 Answers

Try the below:

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

To tint the non active buttons, put the below code in your VC's 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]; 

You need to do this for all the tabBarItems, and yes I know it is ugly and hope there will be cleaner way to do this.

Swift:

UITabBar.appearance().tintColor = UIColor.red  tabBarItem.image = UIImage(named: "unselected")?.withRenderingMode(.alwaysOriginal) tabBarItem.selectedImage = UIImage(named: "selected")?.withRenderingMode(.alwaysOriginal) 
like image 177
Tarek Hallak Avatar answered Oct 14 '22 09:10

Tarek Hallak


There is an much easier way to do this.

Just open the file inspector and select a "global tint".

You can also set an app’s tint color in Interface Builder. The Global Tint menu in the Interface Builder Document section of the File inspector lets you open the Colors window or choose a specific color.

Also see:

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

like image 35
herdi Avatar answered Oct 14 '22 09:10

herdi