Swift를 사용하여 UITextView의 텍스트 색상 일부를 변경하는 방법
let attrText = NSMutableAttributedString(string: "rich text")
attrText.addAttribute(NSForegroundColorAttributeName, value: UIColor.redColor(), range: NSMakeRange(0, 4))
textView.attributedText = attrText
위에서 설명한 대로 문자 색상을 변경하는 방법이지만 문자의 배경색(N S B a c kgroundColorAttributeName) 등을 변경할 수도 있습니다.
또 UIlabel과 UItextField도 같은 문자 장식을 할 수 있다.
Reference
이 문제에 관하여(Swift를 사용하여 UITextView의 텍스트 색상 일부를 변경하는 방법), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다 https://qiita.com/hitting1024/items/5a8313db27f4a2acc8c2텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
우수한 개발자 콘텐츠 발견에 전념 (Collection and Share based on the CC Protocol.)