Search code examples
iosuitabbarcontrolleruitabbaruitabbaritem

How do I add a background Image for individual UITabItem in iOS5?


I am very much new to iOS.

I am trying to create a customized Tab Bar for my app. I tried the following code

UIImage *tabBackground = [[UIImage imageNamed:@"image1"] 
                          resizableImageWithCapInsets:UIEdgeInsetsMake(0, 0, 0, 0)];
[[UITabBar appearance] setBackgroundImage:tabBackground];
[[UITabBar appearance] setSelectionIndicatorImage:
[UIImage imageNamed:@"image2"]];

This set the background for the Tab bar as wel as a different image for the selected tab. My problem is that I want to set different background images for the tabitem instead of just one (for the tab bar).

I want to do this because I want to build a tab bar in the following way (I know its a bad drawing).

|===============/-----\===============|
|       |      |       |      |      | 
| item1 | item2| item3 | item4| item5|
|====================================|

The middle item is more bigger then the other items.

How can I do this?


Solution

  • Try this tutorial out and learn. Pretty much it's what you're looking for: http://idevrecipes.com/2010/12/16/raised-center-tab-bar-button/