设置
isEditable = false或文本视图将在用户点击时进入文本编辑模式。Swift 4及更高版本
let attributedString = NSMutableAttributedString(string: "Just click here to register")let url = URL(string: "https://www.apple.com")!// Set the 'click here' substring to be the linkattributedString.setAttributes([.link: url], range: NSMakeRange(5, 10))self.textView.attributedText = attributedStringself.textView.isUserInteractionEnabled = trueself.textView.isEditable = false// Set how links should appear: blue and underlinedself.textView.linkTextAttributes = [ .foregroundColor: UIColor.blue, .underlineStyle: NSUnderlineStyle.single.rawValue]
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)