Tab bar icons always have a grey tint by default and a blue gradient when selected. That is all good but what happens if this colour scheme does not fit your design.?
Here is how to change that.
UIImage* icon1 = [UIImage imageNamed:@"icon1"]; UITabBarItem *updatesItem = [[UITabBarItem alloc] initWithTitle:@"Label 1"; image:icon1 tag:0]; [updatesItem setFinishedSelectedImage:icon1 withFinishedUnselectedImage:icon1]; [navigationController setTabBarItem:updatesItem]; |
What this does is to make sure both the selected and unselected images are set to the same image. You can change it to two different images if you wish.
Hello,
I am a liitle newbie in Ios…where I have to put this code? in which method in the controller?
You can do this in the viewDidLoad method of your UIViewController
How about if you have several UITabBarItems. the [self setTabBarItem:…] only works for one of the UITabBarItems.
I figured it out.
Hi Jennifer, you can do it in each view controller that belongs to the tab item. Was just about to say before you figured it out 🙂
Hi Tope,
Thanks again for your excellent example that solved my problem of changing to color of a tab bar image when selected or not selected. Thanks so much for you interest in helping us new to iOS programming improve the appearance of our apps.
Hi Tope,
Do you know if this is doable in Buzztouch?? If yes, do you know where to put in the code in this particular dev.prog?
Best
Peter
I got an error.
No Known class method for selector ‘setTabBarItem’
How can i resolve it?
Hi Cipriano,
Please make sure the object you are calling setTabBarItem is a navigationController or UIViewController.
We are using the selector documented here
http://developer.apple.com/library/ios/documentation/uikit/reference/UIViewController_Class/Reference/Reference.html#//apple_ref/occ/instp/UIViewController/tabBarItem
Hi,
Will you please help me for how to design transparent uitabbar like http://www.appdesignvault.com/portfolio/layerblur design