Modify title and icon of a uitabbarcontroller item
Asked Answered
P

1

6

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

Pianist answered 17/3, 2012 at 9:5 Comment(3)
Yes, you can do it programetically as well directly from IB too.I suggest you to start a New Project of type Tabbed Application in XCode. You'll get your answer.Fineable
I have already a TabBarController, and when i add a segue, i can see a tab bar item created but i can't select itPianist
i'm trying to do that in IB, i don't have codePianist
S
13

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

Singhal answered 17/3, 2012 at 9:22 Comment(4)
I use storyboard, and the problem is that i can see in IB when i add a segue, but in the left in IB, there is no items created under the tabBarPianist
did you add the correct segue? It has to be "Relationship - View Controllers"Singhal
strange. So your storyboard doesn't look like the one in my screenshot? Did you change "Simulated Metrics" - "Bottom Bar" of the view controller in the attributes panel?Singhal
I was trying to edit the item in the TabBarController, thanks a lotPianist

© 2022 - 2024 — McMap. All rights reserved.