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?
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
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)]
回答2:
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)
回答3:
Here's the same trick with Interface builder:
回答4:
You can do it directly from Interface Builder (Custom Offset in Title Position), like this:
回答5:
I've found the answer here: ios tabbar put text in the middle when no image will try this one and see how it goes :)
Update: It works. Only 1 line of code.