我的导航栏中有一个标题,我想将其更改为自定义字体。我找到了这行代码,但它适用于具有导航 Controller 的情况。
self.navigationController?.navigationBar.titleTextAttributes = [ NSFontAttributeName: UIFont(name: "LeagueGothic-Regular", size: 16.0)!,
NSForegroundColorAttributeName: UIColor.whiteColor()]
但是我没有任何导航 Controller 。我手动将导航栏添加到我的 View 中。
如何更改评论字体?
最佳答案
试试这个:
objective-C
[[UINavigationBar appearance] setTitleTextAttributes:attrsDictionary];
swift 3
self.navigationController.navigationBar.titleTextAttributes = [NSFontAttributeName: UIFont(name: "CaviarDreams", size: 20)!]
swift 4
self.navigationController.navigationBar.titleTextAttributes = [NSAttributedStringKey.font: UIFont(name: "CaviarDreams", size: 20)!]
关于ios - 更改导航栏标题字体 - swift,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39438606/