In iOS 7, I been developing an app that uses the UITabBarController and I noticed that the tab bar items stay gray even tho I change the tint color of the tab bar. Is there any way to change the color of non-selected tab bar items?
Asked
Active
Viewed 2.6k times
6
-
1This tutorial can be useful for you: https://www.captechconsulting.com/blog/steven-beyers/ios-7-tutorial-series-tint-color-and-easy-app-theming – Robert Jan 26 '14 at 08:03
-
1Above link does not work. @roher. – Arpit B Parekh Nov 09 '16 at 12:29
3 Answers
6
To do this:: follow a simple approach..
Change tintColor as you want
Add a new set of images for unselected items and render them in original mode.
For more info, read through this link

Community
- 1
- 1

Balram Tiwari
- 5,657
- 2
- 23
- 41
-
Put a correct coloured image is solution, and renderMode should be original is a solution. – Arpit B Parekh Nov 09 '16 at 12:36
6
To sets the tint color globally for the app, you need to add below code In app delegate didFinishLaunchingWithOptions: method
:
[[UITabBar appearance] setTintColor:[UIColor colorWithRed:13.0/255.0 green:116.0/255.0 blue:128.0/255.0 alpha:1.0]];

Brian Tompsett - 汤莱恩
- 5,753
- 72
- 57
- 129

Iya
- 1,888
- 19
- 12
-
1Please consider editing your answer to include an explanation of how your code works. – Matt Oct 21 '15 at 05:30
0
Changing the tabBar.tintColor
property is the right way to do it, however to make it work we need to tell iOS to ignore color properties of the UIImage
in TabBarItem
.
Hence write this code in your custom TabBarViewController
's viewDidLoad()
for item in self.tabBar.items ?? [] {
item.selectedImage = item.selectedImage?.withRenderingMode(.alwaysTemplate)
item.image = item.image?.withRenderingMode(.alwaysTemplate)
}

MMujtabaRoohani
- 483
- 4
- 19