Reda
Reda

Reputation: 1335

Modify title and icon of a uitabbarcontroller item

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

Upvotes: 6

Views: 8839

Answers (1)

Matthias Bauch
Matthias Bauch

Reputation: 90117

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

Upvotes: 13

Related Questions