在网上搜索如何调整UITabBarItem标题的位置时,我遇到了类似的this帖子,但我仍然不知道该怎么做。
甚至可以从下往上调整一下标题的位置吗?(例如5px)我需要这个,因为我有自定义图像,而现在标题的位置并不完美。
发布于 2012-04-17 23:02:07
为什么不为视图控制器设置一个空的title属性,并将标题添加到选项卡的自定义图像中呢?
您可以这样做(在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];其中tabIconSelected.png和tabIconNotSelected.png都包含选项卡的标题文本。
我已经写了一篇简短的文章"Add some colour to your UITabBar icons",其中解释了如何使用标签自定义图像。
希望这能有所帮助。
发布于 2012-12-18 23:03:29
如果要向上移动,只需将垂直偏移量设置为负值
UITabBarItem* it = [[self.tabController.tabBar items] objectAtIndex:0];
it.titlePositionAdjustment = UIOffsetMake(0.0, -2.0);您不必使用proxy,因为它是在这里完成的,UITabBarItem title in centre of title, not at bottom.You可以定义每个项目的偏移量。
发布于 2016-08-30 19:48:50
懒惰人的Swift版本:)
UITabBarItem.appearance().titlePositionAdjustment = UIOffsetMake(0.0, -4.0)https://stackoverflow.com/questions/10192665
复制相似问题