简体   繁体   English

更改导航栏项目的字体大小

[英]changing navigation bar item font size

How can i only change the size of the navigation bar items on swift? 如何仅迅速更改导航栏项目的大小? I tried the following: 我尝试了以下方法:

UINavigationBar.appearance().titleTextAttributes =
[ NSFontAttributeName: UIFont(name:"CaviarDreams", size: 20)!]

but this also changes the font. 但这也会更改字体。 Is there any function only for the font size? 仅字体大小有功能吗?

This can obviously be done programmatically, like you have mentioned, but I'm not sure if there's a method to create a UIFont with only a size. 显然,可以像您提到的那样通过编程方式完成,但是我不确定是否有一种方法可以创建只有大小的UIFont。 You could create one with the system font and only modify the size but I'm not sure if that's what you want. 您可以使用系统字体创建一个字体,仅修改其大小,但是我不确定这是否是您想要的。

There is a [fontWithSize] method that you can call on a font that you have already instantiated but I also don't think this is what you want. 有一个[fontWithSize]方法可以调用已经实例化的字体,但我也不认为这是您想要的。

You can however change the font size in Interface Builder: 但是,您可以在Interface Builder中更改字体大小:

在此处输入图片说明

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM