Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to remove icons on the UITabBar

Basically, I want to remove the default icons on the UITabBar and only show the titles. Besides, I hope to position the titles of the tab bar at the center of the tab bar, instead of the default one. Does anybody know how to remove the icons and center the titles? Thanks!

like image 814
Mike Zhu Avatar asked Dec 04 '25 04:12

Mike Zhu


2 Answers

Code in Objective-C

self.tabBarItem = [[UITabBarItem alloc] initWithTitle:@"Tab1" image:nil selectedImage:nil];
[self.tabBarItem setTitlePositionAdjustment:UIOffsetMake(0, -10)];
like image 153
Ruchish Shah Avatar answered Dec 06 '25 23:12

Ruchish Shah


As usual this is easier in code than in Interface Builder.

For Swift in XCode 9.0 and Swift 4.0:

self.tabBarItem = UITabBarItem(title: "Your Title", image: nil, selectedImage: nil)
like image 38
Pigpocket Avatar answered Dec 06 '25 23:12

Pigpocket



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!