titleTextAttributes UIAppearance font in iOS 7

前端 未结 7 1582
醉酒成梦
醉酒成梦 2020-12-08 09:47

I am using UIAppearance to apply fonts to UINavigationBar and UIBarButtonItem and I am having problems. I ran this code:

[[UIBarButtonItem appearanceWhenCont         


        
7条回答
  •  一生所求
    2020-12-08 10:25

    Here it is in Swift:

    let font = UIFont(name: "My_Font", size: 17.0)
    UINavigationBar.appearance().titleTextAttributes = [
        NSForegroundColorAttributeName: UIColor.whiteColor(),
        NSFontAttributeName: font!
    ]
    

    *Note that you have to unwrap the optional UIFont.

提交回复
热议问题