我把标题放在nevegationItem中:
let navigationItem = UINavigationItem()
navigationItem.title = "Title"
navigationBar.items = [navigationItem]
这很有效......但是。
如何更改标题文本的大小??
答案 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)!]
答案 2 :(得分:0)
Swift 4.2
更改大标题
self.navigationController!.navigationBar.largeTitleTextAttributes = [.font: UIFont.systemFont(ofSize: 22)]
更改小标题 向下滚动版式
self.navigationController!.navigationBar.titleTextAttributes = [.font: UIFont.systemFont(ofSize: 14)]