2016-09-18 48 views
1

在我的故事板中,TableViewController中的導航欄的標題默認爲粗體(沒有選項可以更改它)。但是,當我在模擬器和iPhone 6S上運行應用程序時,標題爲而不是以粗體顯示。下面的兩個屏幕截圖將顯示不同之處。我沒有找到任何設置來更改界面生成器中的字體。我不知道這是環境更新到iOS 10.無代碼更改任何視覺,一切都在界面生成器做之前不正確TableViewController導航欄標題不是粗體

Interface Builder

Simulator

回答

0

嘗試

self.navigationController?.navigationBar.titleTextAttributes = 
[NSFontAttributeName: UIFont(name: "your-bold-font", size: 21)!] 
0

只需創建一個標籤並將其添加到您的導航項中:

let title = UILabel(frame: CGRect(x: 0, y: 7, width: 200, height: 30)) 
title.textAlignment = NSTextAlignment.center 
title.textColor = UIColor.white 
title.text = "Test heading" 
title.font = UIFont.boldSystemFont(ofSize: 20) 

let titleView = UIView(frame: CGRect(x: deviceHelper.screenWidth/2, y: 0, width: 200, height: 44)) 
titleView.backgroundColor = UIColor.clear 
self.navigationItem.titleView = titleView 
titleView.addSubview(title)