我只能在标签栏项目中显示文本并更改样式和位置吗 [英] Can i only display text in tab bar item and change the style and position

查看:96
本文介绍了我只能在标签栏项目中显示文本并更改样式和位置吗的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在情节提要板中添加了一个标签栏,并且不想为该标签栏项设置图像,如下所示:

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

如何在Storybord中更改栏项目标题的字体和位置?

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

推荐答案

首先在情节提要中选择选项卡栏项,然后在属性检查器"中将系统项"和标题位置"设置为自定义",这样就可以更改通过将值设置为水平"和垂直"框来获得标题.

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.

最后,要更改字体,请在您的viewDidLoad()中包括:

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允许您更改字体样式,而NSForegroundColorAttributeName允许您更改字体颜色.

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

这篇关于我只能在标签栏项目中显示文本并更改样式和位置吗的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆