Vor*_*ork 4 ios nsattributedstringkey swift4.2
从 swift 3 升级到 swift 4.2 时出现以下两行代码错误
let lineattribute : [String: Any] = [
NSForegroundColorAttributeName : UIColor(hexString: "#0f88b7ff")!,
NSUnderlineStyleAttributeName : NSUnderlineStyle.styleSingle.rawValue
]
let attributeString = NSMutableAttributedString(string: "View travelling details", attributes: lineattribute)
Run Code Online (Sandbox Code Playgroud)
Eru*_*aru 11
在Swift 4.2 中,你必须使用NSAttributedString.Key而不是String
let lineattribute : [NSAttributedString.Key : Any] = [
.foregroundColor : UIColor(hexString: "#0f88b7ff"),
.underlineStyle : NSUnderlineStyle.styleSingle.rawValue
]
let attributeString = NSMutableAttributedString(string: "View traveling details", attributes: lineattribute)
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3190 次 |
| 最近记录: |