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.

10 comments

  1. Mario

    Hello,

    I am a liitle newbie in Ios…where I have to put this code? in which method in the controller?

  2. Chicygeek

    How about if you have several UITabBarItems. the [self setTabBarItem:…] only works for one of the UITabBarItems.

  3. Ron Behee

    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.

  4. Peter

    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