Change UINavigationBar font properties?

前端 未结 7 428
清酒与你
清酒与你 2020-12-24 05:42

I have an UINavigationBar added to my UIViewController view. I want to change the fonts properties. Note that I want to change a UINavigationBar not controller. In my app wh

7条回答
  •  自闭症患者
    2020-12-24 05:46

    For iOS 13 and Swift 5.

    For setting the title color & font just add in viewDidLoad() the following line:

    UINavigationBar.appearance().titleTextAttributes = [
        .foregroundColor: UIColor.white, 
        .font: UIFont(name: "Arial", size: 24)! ]
    

    For setting the bar button item text color & font:

    UIBarButtonItem.appearance().setTitleTextAttributes([
        .foregroundColor: UIColor.white, 
        .font: UIFont(name: GetFontNameBold(), size: 40)! ],
        for: UIControl.State.normal)
    

提交回复
热议问题