Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7084119
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T07:15:43+00:00 2026-05-28T07:15:43+00:00

I have a tab bar controller (its a tab bar based application, so tab

  • 0

I have a tab bar controller (its a tab bar based application, so tab bar is on MainWindow.xib). In this xib, I have added 4 tab bar items and I have set the image of all tab bar item. Due to this, I am facing 2 issues:

1) The image is white-colored, but when I run the application, its showing all the images on tab bar item as gray colored. How can I make it look same as is in the original image.

2) I have a selected image, that I want to add on the tab bar item which is currently selected. How should I do this???

UPDATED AFTER NICK’s CODE:

Hey, in iOS 5, you will have to write following code in your app delegate for setting tab bar item selected and unselected image (the category solution will work only on 4):

if ([[[UIDevice currentDevice] systemVersion] floatValue]>4.9) {
    NSString *selectedImageName,*unselectedImageName;

    for (int counter = 0; counter < [self.tabBarController.tabBar.items count]; counter++) {
        if (counter==0) {
            selectedImageName = <someImagename>;
            unselectedImageName = <someImagename>;
        }
        else if (counter==1) {
            selectedImageName = <someImagename>;
            unselectedImageName = <someImagename>;
        }
        .
                    .
        else {
            selectedImageName = <someImagename>;
            unselectedImageName = <someImagename>;
        }
        UIImage *selectedImage = [UIImage imageNamed:selectedImageName];
        UIImage *unselectedImage = [UIImage imageNamed:unselectedImageName];

        UITabBarItem *item = [self.tabBarController.tabBar.items objectAtIndex:counter];
        if ([item respondsToSelector:@selector(setFinishedSelectedImage:withFinishedUnselectedImage:)]) {
            [item setFinishedSelectedImage:selectedImage withFinishedUnselectedImage:unselectedImage];
        }
    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T07:15:44+00:00Added an answer on May 28, 2026 at 7:15 am

    Add this category to your project. It will force tab bar items to use your original image as the disabled state instead of applying a grey gradient to them:

    @implementation UItabBarItem (CustomUnselectedImage)
    
    - (UIImage *)unselectedImage
    {
        return self.image;
    }
    
    @end
    

    This may seem like it is using private APIs but I’ve seen this used multiple times on apps that were approved. It’s not actually calling a private method, just overriding one.

    If you need to specify different images for the selected and unselected image, your best bet is probably to use the tag property of the UITabBarItem and a switch statement, like this:

    @implementation UItabBarItem (Custom)
    
    - (UIImage *)selectedImage
    {
        switch (self.tag)
        {
            case 1:
                return [UIImage imageNamed:@"tab-selected1.png"];
            case 2:
                return [UIImage imageNamed:@"tab-selected2.png"];
            etc...
        }
    }
    
    - (UIImage *)unselectedImage
    {
        switch (self.tag)
        {
            case 1:
                return [UIImage imageNamed:@"tab-unselected1.png"];
            case 2:
                return [UIImage imageNamed:@"tab-unselected2.png"];
            etc...
        }
    }
    
    @end
    

    Then in interface builder, don’t bother with setting the tab bar item images as they’ll just be ignored. Instead, set their tags to match up with the images you’ve specified in your switch statements.

    Note that if you have multiple tab bars in your app, and you don’t want them to all be overridden in this way, you can define these methods on a subclass of UITabBarItem instead of as a category. Then you can set the class of the tab bar items in your nib file to be your custom subclass instead of regular UITabBarItems, and only those ones will be affected.

    EDIT:

    Note that as of iOS 5 there is a better way of doing this using the UIAppearance APIs. This technique should still work, but who knows if Apple might start cracking down on it now that there is an officially supported approach. Better to use the new method unless you really need iOS 4 support.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an application set up where the window contains a tab bar controller
I have a tab bar controller and in both tab bar items i have
Let's have an example. In application I have a tab bar controller. Tab bar
I have a tab-bar and navigation controller application (like Youtube app or Contacts app).
I have an application with a tab bar controller and each view contains a
I have a tab bar application that contains navigation views in 2 of its
I have a tab based application with a navigation controller in it. When i
I have a tab bar application with a navigation controller and view controllers inside
I have a tab bar application and when I display a modal view controller,
i have a tab bar controller as a root controller. In its first tab

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.