更改 NavigationItem 标题大小

Changing NavigationItem title size

我把标题放在nevegationItem中:

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

这很完美...但是

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

您在导航栏中设置了字体…

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

使用字体属性更改标题字体

self.navigationController.navigationBar.titleTextAttributes = [ NSFontAttributeName: UIFont(name: "CaviarDreams", size: 20)!]

找到:How do i change navigationBar font in Swift?

Swift 4.2

Change Large Title

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

Change Small Title when layout scrolled down

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