Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UITabBarItem title position

On searching the web on how to adjust the position of a UITabBarItem title position i ran over this similar post and still wondering how to do that.

Is it even possible to adjust the title position a bit from the bottom up? (for example 5px) I need this because i have custom images and now the position of the title is not perfect.

like image 424
user944351 Avatar asked Apr 17 '12 13:04

user944351


3 Answers

If you want to move up simply set vertical offset to negative value

UITabBarItem* it = [[self.tabController.tabBar items] objectAtIndex:0];
it.titlePositionAdjustment = UIOffsetMake(0.0, -2.0);

You don't have to use proxy as it is done here UITabBarItem title in centre of title, not at bottom.You can define offset per item.

like image 118
Radek Avatar answered Nov 02 '22 15:11

Radek


If you want to update all of them:

tabBar.items?.forEach({ $0.titlePositionAdjustment = UIOffset(horizontal: 0.0, vertical: -2.0) })
like image 42
pierre23 Avatar answered Nov 02 '22 13:11

pierre23


Swift version for the lazy ones :)

UITabBarItem.appearance().titlePositionAdjustment = UIOffsetMake(0.0, -4.0)
like image 38
ergunkocak Avatar answered Nov 02 '22 15:11

ergunkocak