4

I have customized a Tab Bar using the methods from Ray Wenderlich and iOS Blog but because I'm using a light color as background the text labels look awful and I want to change them to match my style. Is it possible and how?

If its not possible or if its too complex I would like to ask how to move the icon image down so its centered on the Tab Bar? This way I could "write" the labels on the .png files.

I'm planning on developing this app for iOS5+ so there is no worry about making it compatible with iOS4 (although if anyone finds a easy way of doing this I would really appreciate).

Here's what I got so far and here's what I want.

The code for my tabBarBackground:

UIImage* tabBarBackground = [UIImage imageNamed:@"tabbar.png"];
[[UITabBar appearance] setBackgroundImage:tabBarBackground];

[[UITabBar appearance] setSelectionIndicatorImage:[UIImage imageNamed:@"selection-tab.png"]];

And for the Icons:

//Custom TabBar Items
UIImage *selectedImage = [UIImage imageNamed:@"home-icon-selected.png"];
UIImage *unselectedImage = [UIImage imageNamed:@"home-icon.png"];

UITabBar *tabBar = rootTabBarController.tabBar;
//Icons for the 1st Tab
UITabBarItem *item1 = [tabBar.items objectAtIndex:0];
[item1 setFinishedSelectedImage:selectedImage withFinishedUnselectedImage:unselectedImage];
Tony
  • 41
  • 3

2 Answers2

2

You can do this by accessing the tab-bar item object of the tabbar for each view controller. Check out some documentation here for more examples.

http://developer.apple.com/library/ios/#featuredarticles/ViewControllerPGforiPhoneOS/CombiningViewControllers/CombiningViewControllers.html

Rich86man
  • 6,507
  • 2
  • 26
  • 27
-1

Use this to customize UITabBarItem text:

[[UITabBarItem appearance] setTitleTextAttributes: aNSDictionaryOfTextAttributes];

with a dictionary of attributes similar to those shown in the answer here.

Community
  • 1
  • 1
Jeremy
  • 1,029
  • 10
  • 18