Quick Tip: Adding icons to Three20 Tab Bar
I’m using the Three20 Additions to UITabBarController for the Green Ninja Active City Guide iPhone app (based on TTNavigatorDemo). This is great, except all the examples I found for tab bar images use the controller to set the tab bar item. With Three20, that didn’t work, so I had to add some code to my TabBarController to get icons.
In the code below, the first part of the method sets up the tab bar for three URLs/controllers, and the second part of the method adds the images.
Has anyone else used a different approach to get icons on a Three20 application tab bar?
- (void)viewDidLoad {
[super viewDidLoad\];
[self setTabURLs:\[NSArray arrayWithObjects:
@"http://www.greenninja.com/city-guide/austin",
@"http://www.greenninja.com/activities/austin",
@"tt://map",
nil]];
NSArray *tabs = [self viewControllers];
UIViewController *home = [tabs objectAtIndex:0];
home.tabBarItem.image = [UIImage imageNamed:@"house.png"];
UIViewController *activities = [tabs objectAtIndex:1];
activities.tabBarItem.image = [UIImage imageNamed:@"star.png"];
UIViewController *map = [tabs objectAtIndex:2];
map.tabBarItem.image = [UIImage imageNamed:@"world.png"];
}