UITabBarItem Position Position

When searching the Internet for how to adjust the position of a UITabBarItem position, I looked at this similar post and still wondered how to do this.

Is it even possible to slightly change the position of the title from the bottom up? (e.g. 5px) I need this because I have custom images and now the position of the header is not perfect.

+7
source share
5 answers

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

You can do this (in iOS 5.0):

UIImage* iconSelected = [UIImage imageNamed:@"tabIconSelected.png"];
UIImage* iconNotSelected = [UIImage imageNamed:@"tabIconNotSelected.png"];
UITabBarItem *updatesListItem = [[UITabBarItem alloc] initWithTitle:@"" image:iconSelected tag:0];
[updatesListItem setFinishedSelectedImage:iconSelected withFinishedUnselectedImage:iconNotSelected];
[navigationController setTabBarItem:updatesListItem];

where tabIconSelected.pngand tabIconNotSelected.pngboth contain the header text for the tab.

" UITabBar" , , .

, .

+1

,

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

-, UITabBarItem , . .

+14

:)

UITabBarItem.appearance().titlePositionAdjustment = UIOffsetMake(0.0, -4.0)
+10

objective-C:

[[UITabBarItem appearance] setTitlePositionAdjustment:UIOffsetMake(0, -4)];
+1

:

tabBar.items?.forEach({ $0.titlePositionAdjustment = UIOffset(horizontal: 0.0, vertical: -2.0) })
0

All Articles