-1

I run this code in 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]

I get error:

[__SwiftValue integerValue]: unrecognized selector sent to instance 0x600002ba3b10

I don't know what is wrong.

xyz_abc
  • 1
  • 2

1 Answers1

1

Use this NSUnderlineStyle.single.rawValue

instead of NSUnderlineStyle.single

textView?.linkTextAttributes = [.foregroundColor: UIColor.blue, .underlineColor: UIColor.blue, .underlineStyle: NSUnderlineStyle.single.rawValue]
AjinkyaSharma
  • 1,870
  • 1
  • 16
  • 26
Chaman Sharma
  • 641
  • 5
  • 10