Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 297
Reda Avatar asked Mar 17 '12 09:03

Reda


People also ask

How do I change the tab title color in Swift bar?

backgroundColor = UIColor(red:1, green:0, blue:0, alpha:1) / UITabBar. appearance(). tintColor = UIColor(red: 1, green: 0, blue: 0, alpha: 1) // New!! func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {...}

How do I change the color of my TabBar text?

To change the text color for selected state, inside the TabBar widget, add the labelColor property and set the color. To change the text color for the unselected state, add the unselectedLabelColor parameter and change it colors.


1 Answers

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

like image 64
Matthias Bauch Avatar answered Sep 28 '22 19:09

Matthias Bauch