在更新到Xcode 6.1之前,以下代码运行正常,以便与iOS 8.1保持同步:
override func viewDidAppear(animated: Bool) {
self.navigationController?.navigationBar.topItem?.title = "Home"
self.navigationController?.navigationBar.titleTextAttributes = [ NSFontAttributeName: UIFont(name: "Lobster 1.4", size: 34), NSForegroundColorAttributeName: UIColor.whiteColor()]
}
Run Code Online (Sandbox Code Playgroud)
问题具体在于 NSFontAttributeName: UIFont(name: "Lobster 1.4", size: 34)
而我在这里得到的错误是:
! "Could not find an overload for 'init' that accepts the supplied arguments"
我在另一个StackOverflow问题上找到了这个原始代码,它在预期之前正常工作,直到此更新(昨天下载).我的字体确实正确安装.
我现在应该以不同的方式编写此代码,还是有一种全新的方式来设置导航栏字体?
谢谢!