Swift 4迁移获取错误无法转换类型' [String:AnyObject]的值?'预期的参数类型' [NSAttributedStringKey:Any]?'

时间:2017-10-30 12:03:03

标签: migration ios11 swift4

let linkTextAttributes = [
        NSAttributedStringKey.underlineStyle: NSNumber(value: NSUnderlineStyle.styleSingle.rawValue as Int),
        NSAttributedStringKey.foregroundColor: FAColor.blackColor()
      ]

self.lblPinDidNotMatchDescription.linkTextAttributes = linkTextAttributes

在Swift 4迁移时出错

  

"无法转换类型' [String:AnyObject]的值?'预期参数类型' [NSAttributedStringKey:Any]?'"。

任何帮助?

1 个答案:

答案 0 :(得分:0)

更改为NSUnderlineStyle.styleSingle.rawValue

实施例

let linkTextAttributes: [NSAttributedStringKey: Any]  = [
                    NSAttributedStringKey.underlineStyle: NSUnderlineStyle.styleSingle.rawValue,
                    NSAttributedStringKey.foregroundColor: UIColor.black
                ]