Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a way to change the text position in UITabBar or UITabBarItem?

enter image description here

This is a custom tab bar I intended to put up on the screen. However, my partner want the text to be slightly up. How can I do so?

like image 291
user4234 Avatar asked Nov 29 '12 03:11

user4234


2 Answers

Why don't you just have an empty title property for your view controller and add the title to your custom images for the tab?

UPDATE: For the sake of completeness of answer; from comments and ios tabbar put text in the middle when no image

[tab.tabBarItem setTitlePositionAdjustment:UIOffsetMake(0, -10)]

like image 150
Srikar Appalaraju Avatar answered Oct 03 '22 04:10

Srikar Appalaraju


You probably want to apply this offset globally, so I'd suggest

Obj-C

[UITabBarItem appearance].titlePositionAdjustment = UIOffsetMake(0, -4); 

Swift:

UITabBarItem.appearance().titlePositionAdjustment = UIOffset(horizontal: 0, vertical: -4) 
like image 33
Tim Windsor Brown Avatar answered Oct 03 '22 05:10

Tim Windsor Brown