Modify title and icon of a uitabbarcontroller item

Reda picture Reda · Mar 17, 2012 · Viewed 8.8k times · Source

How can I modify the title and the icon of items of TabBarController? It is possible directly in Interface Builder?

Answer

Matthias Bauch picture Matthias Bauch · Mar 17, 2012

in code:

UITabBarItem *tabBarItem = [[UITabBarItem alloc] initWithTitle:@"Fancy Tab" image:[UIImage imageNamed:@"FancyTab"] tag:1];
myViewController.tabBarItem = tabBarItem; // to set the tabBarItem from outside the viewController
self.tabBarItem = tabBarItem;             // to set the tabBarItem from inside the viewController

in regular .xib: click the item in the tabBarController. And then click it again. You can now edit title and icon in the attribute inspector.

in storyboard: click the item in the viewController that is connected to the tabBarController (not in the tabBarController itself). This time one click is enough. And set title and icon in the attribute inspector.

enter image description here