, , .
UITextView
:
, UITextView
textView, attributeString
-
<a href="mailto:email@example.com\>mailto_test</a>
documentType
- html. :
let textView = UITextView(frame: view.bounds)
textView.frame.origin.y += 100
let attrStr = try! NSAttributedString(
data: "<a href=\"mailto:email@example.com\">mailto_test</a>".data(using: .utf8, allowLossyConversion: true)!,
options:[.documentType: NSAttributedString.DocumentType.html],
documentAttributes: nil)
textView.attributedText = attrStr
view.addSubview(textView)
, mailto_test
. delegate
textView
click.
textView.isEditable = false
textView.dataDetectorTypes = .link
textView.delegate = self
:
func textView(_ textView: UITextView, shouldInteractWith URL: URL, in characterRange: NSRange, interaction: UITextItemInteraction) -> Bool {
print(URL)
return false
}
, , . URL- - .