问题
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