UITextView with hyperlink text

后端 未结 10 842
抹茶落季
抹茶落季 2020-11-27 19:23

With a non-editable UITextView, I would like to embed text like this in iOS9+:

Just click here to register

I can create a functi

10条回答
  •  情书的邮戳
    2020-11-27 20:08

    Using Swift >= 4:

    let descriptionText = NSMutableAttributedString(string:"To learn more, check out our ", attributes: [:])
    
    let linkText = NSMutableAttributedString(string: "Privacy Policy and Terms of Use", attributes: [NSAttributedString.Key.link: URL(string: example.com)!])
    
    descriptionText.append(linkText)
    

提交回复
热议问题