-2

I am now working in a universal application. Here the deployment target i iOS 6.0 and I am working on Xcode 6.0.1 with Objective-C. I am facing problem to put image on tab bar items. I will have 6 or 7 tab bar items in the tab bar controller, so that by default a “More” button will appear.

I need to set image on each tab bar item.

I need help.

alexwlchan
  • 5,699
  • 7
  • 38
  • 49
Bis
  • 713
  • 1
  • 5
  • 7

2 Answers2

0

If the tab bar controller is your root view controller, you could probably do this in 'didFinishLaunching..' in appdeleagte.

UITabBarController *tabBarController=(UITabBarController*) (self.window.rootViewController);
UITabBar *tabBar=tabBarController.tabBar;
UITabBarItem *tabBarItem1=[[tabBar items] objectAtIndex:0];//first tab bar
UIImage* selectedImage = [[UIImage imageNamed:@"yourImage"] imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate];
[tabBarItem1 setImage:selectedImage];
Alejandro Vargas
  • 1,327
  • 12
  • 26
0

Add custom image to Tabbar

UITabBarItem *first = [[UITabBarItem alloc]initWithTitle:@"First" image:[UIImage imageNamed:@"first.png"] selectedImage:[UIImage imageNamed:@"second.png"]];
[self.tabBarController setTabBarItem:first];
Ramesh
  • 102
  • 11