0
我有文本框,我想获取一些可点击的文本。以下是我的代码请审查和感谢。在Swift中使用超链接文本的UITextView
let string = "Google"
let linkString = NSMutableAttributedString(string: string)
linkString.addAttribute(NSLinkAttributeName, value: NSURL(string: "https://www.google.com")!, range: NSMakeRange(0, string.characters.count))
linkString.addAttribute(NSFontAttributeName, value: UIFont(name: "HelveticaNeue", size: 25.0)!, range: NSMakeRange(0, string.characters.count))
textView.attributedText = linkString
textView.selectable = true
textView.userInteractionEnabled = true
使用的TextView为你的概念,而不是文本框的 –