Swift 4 Conversion error - NSAttributedStringKey: Any

前端 未结 4 1998
孤城傲影
孤城傲影 2020-12-01 10:23

I converted my app recently and I keep getting the error

\"Cannot convert value of type \'[String : Any]\' to expected argument type \'[NSAttributedS

4条回答
  •  盖世英雄少女心
    2020-12-01 10:56

    Its expecting NSAttributedStringKey(NSAttributedStringKey.font) and you are sending String(NSAttributedStringKey.font.rawValue).

    So please replace NSAttributedStringKey.font.rawValue with NSAttributedStringKey.font like below :

    let attributes = [NSAttributedStringKey.font:  UIFont(name: "Helvetica-Bold", size: 15.0)!, NSAttributedStringKey.foregroundColor: UIColor.white]
    

提交回复
热议问题