How to change the font and text color of the title of UINavigationBar

前端 未结 6 783
滥情空心
滥情空心 2021-01-07 18:05

I want to be change the font of the title to Avenir, and I want to make it white. Here is my code in the viewDidLoad method:

UINavigationBar.app         


        
6条回答
  •  慢半拍i
    慢半拍i (楼主)
    2021-01-07 18:29

    I would just create an outlet and do this:

    @IBOutlet weak var navigationBar: UINavigationBar!
    override func viewDidLoad() {
        super.viewDidLoad()
        // Do any additional setup after loading the view, typically from a nib.
    
        navigationBar.titleTextAttributes = [NSFontAttributeName: UIFont(name: "Avenir", size: 30)!]
    }
    

提交回复
热议问题