Can i only display text in tab bar item and change the style and position

我们两清 提交于 2020-01-17 09:12:16

问题


I add a tab bar in storyboard, and do not want to set an image to the tab bar item, and like the following:

How can I change the font and the position for the title of the bar item in storybord?


回答1:


First select the tab bar item in storyboard, than in Attributes Inspector set System Item and Title Position to Custom, so you will be able to change the position of the title by setting values to Horizontal and Vertical boxes.

Finally, to change the font, in your viewDidLoad(), include:

UITabBarItem.appearance().setTitleTextAttributes([NSFontAttributeName: UIFont(name: "Avenir-BlackOblique", size:20)!, NSForegroundColorAttributeName: UIColor.blue], for: .normal)

NSFontAttributeName allow you to change the font style and NSForegroundColorAttributeName allow you to change the font color.



来源:https://stackoverflow.com/questions/43410151/can-i-only-display-text-in-tab-bar-item-and-change-the-style-and-position

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!