简体   繁体   English

如何更改UINavigation条形字体

[英]How to change a UINavigation Bar Fonts

I am using this code to change the navigation bar color and font. 我正在使用此代码来更改导航栏的颜色和字体。 How do i make the font thin? 如何使字体变细? I tried adding a font family name, but the app crashed. 我尝试添加字体系列名称,但该应用程序崩溃了。 Please answer in swift. 请迅速回答。

nav?.titleTextAttributes = [NSForegroundColorAttributeName: UIColor.whiteColor(), NSFontAttributeName: UIFont.boldSystemFontOfSize(20)]

use this code : 使用此代码:

self.navigationController.navigationBar.titleTextAttributes = [ NSFontAttributeName: UIFont(name: "CaviarDreams", size: 20)!]
let colorDict: NSDictionary = [NSForegroundColorAttributeName: UIColor.whiteColor()]
self.navigationController.navigationBar.titleTextAttributes = colorDict

Please take a look at your own code, bold is the opposite to thin. 请看一下您自己的代码, 粗体与精简相反。

When you state UIFont.boldSystemFontOfSize(20)] you're telling UIKit to use the default Font with a thick format. 当您声明UIFont.boldSystemFontOfSize(20)]您是在告诉UIKit使用具有格式的默认Font。

UPDATE: 更新:

Use one of these functions instead: 请使用以下功能之一:

UIFont.systemFontOfSize(fontSize: CGFloat, weight: CGFloat)
UIFont.systemFontOfSize(fontSize: CGFloat)

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

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