在AppDelegate.swift中,我有以下代码:

let nav1 = UINavigationController()
    let mainView = ViewController(nibName: nil, bundle: nil) //ViewController = Name of your controller
    nav1.viewControllers = [mainView]
nav1.navigationBar.topItem?.title = "JT"
    nav1.navigationController?.navigationBar.titleTextAttributes = [ NSFontAttributeName: UIFont(name: "AvenirNext-UltraLight", size: 24)!,  NSForegroundColorAttributeName: UIColor.whiteColor()]

但是最后一行不会更改导航栏标题的字体
我该做什么?

最佳答案

您可以通过情节提要更改导航栏标题属性,或尝试以下操作:

nav1.navigationBar.titleTextAttributes = [NSFontAttributeName: UIFont(name: "AvenirNext-UltraLight", size: 24)!,  NSForegroundColorAttributeName: UIColor.whiteColor()]

关于ios - swift:导航栏中的标题字体,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/36386277/

10-10 20:29