Note that there are some explanatory texts on larger screens.

plurals
  1. POtabbar item image and selectedImage
    text
    copied!<p>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:</p> <p>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.</p> <p>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???</p> <p>UPDATED AFTER NICK's CODE:</p> <p>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):</p> <pre><code>if ([[[UIDevice currentDevice] systemVersion] floatValue]&gt;4.9) { NSString *selectedImageName,*unselectedImageName; for (int counter = 0; counter &lt; [self.tabBarController.tabBar.items count]; counter++) { if (counter==0) { selectedImageName = &lt;someImagename&gt;; unselectedImageName = &lt;someImagename&gt;; } else if (counter==1) { selectedImageName = &lt;someImagename&gt;; unselectedImageName = &lt;someImagename&gt;; } . . else { selectedImageName = &lt;someImagename&gt;; unselectedImageName = &lt;someImagename&gt;; } 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]; } } } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload