更改NavigationItem标题大小

时间:2017-03-01 13:42:35

标签: ios swift uinavigationitem

我把标题放在nevegationItem中:

let navigationItem = UINavigationItem()
navigationItem.title = "Title"
navigationBar.items = [navigationItem]

这很有效......但是。

如何更改标题文本的大小??

3 个答案:

答案 0 :(得分:2)

您可以在导航栏中设置字体...

let font = UIFont(name: "Helvetica", size: 22)!
UINavigationBar.appearance().titleTextAttributes = [NSFontAttributeName: font]

答案 1 :(得分:0)

使用字体属性

更改标题字体
self.navigationController.navigationBar.titleTextAttributes = [ NSFontAttributeName: UIFont(name: "CaviarDreams", size: 20)!]

发现:How do i change navigationBar font in Swift?

答案 2 :(得分:0)

Swift 4.2

  

更改大标题

self.navigationController!.navigationBar.largeTitleTextAttributes = [.font: UIFont.systemFont(ofSize: 22)]
  

更改小标题 向下滚动版式

self.navigationController!.navigationBar.titleTextAttributes = [.font: UIFont.systemFont(ofSize: 14)]