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?
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).
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)
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With