Error when instantiating a UIFont in an text attributes dictionary

后端 未结 4 948
北恋
北恋 2020-12-11 01:58

I\'m trying to set the font of the UIBarButtonItem like so:

let barButton = UIBarButtonItem.appearance()
barButton.setTitleTextAttributes([NSFon         


        
4条回答
  •  执念已碎
    2020-12-11 02:08

    With Swift 4

    NSFontAttributeName is deprecated, you can use NSAttributedStringKey values to set attributes.

    if let fontStyle = UIFont(name: "HelveticaNeue-Light", size: 19) {
     navigationController?.navigationBar.titleTextAttributes = [NSAttributedStringKey.font: fontStyle]
    

    }

提交回复
热议问题