Instantly share code, notes, and snippets.

What would you like to do?
UITextView 일부 텍스트에 링크 추가하는 팁
extension UIViewController: UITextViewDelegate {
public func textView(_ textView: UITextView, shouldInteractWith
URL: URL, in characterRange: NSRange,
interaction: UITextItemInteraction) -> Bool {
let urlString = URL.absoluteString
if urlString == "TermLink" {
print("이용약관 링크를 연다")
// 이용약관 화면으로 이동 처리
} else if urlString == "PrivacyLink" {
print("개인정보보호정책 링크를 연다")
// 개인 정보보호정책 화면으로 이동처리
return false
let textString = "이용약관, 개인정보보호정책에 동의합니다."
let attrString = NSMutableAttributedString(string: textString)
attrString.addAttribute(.link, value: "PrivacyLink",
range: NSString(string: textString).range(of: "개인정보보호정책"))
let tv = UITextView()
tv.attributedText = attrString
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment