我在Swift 5,iOS 12.1中运行以下代码:
let linkText = NSMutableAttributedString(string: "this is link", attributes: [.link: NSString(string: "http://example.com")]) textView.attributedText = linkText textView.linkTextAttributes = [.foregroundColor: UIColor.blue, .underlineColor: UIColor.blue, .underlineStyle: NSUnderlineStyle.single]
我收到错误消息:
[__SwiftValue integerValue]: unrecognized selector sent to instance 0x600002ba3b10
我不知道怎么了。
答案 0 :(得分:0)
使用此NSUnderlineStyle.single.rawValue
代替NSUnderlineStyle.single
textView?.linkTextAttributes = [.foregroundColor: UIColor.blue, .underlineColor: UIColor.blue, .underlineStyle: NSUnderlineStyle.single.rawValue]