2016-09-18 184 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)