简体   繁体   中英

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!

Code in Objective-C

self.tabBarItem = [[UITabBarItem alloc] initWithTitle:@"Tab1" image:nil selectedImage:nil];
[self.tabBarItem setTitlePositionAdjustment:UIOffsetMake(0, -10)];

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)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM