[ios] swift NSMutableAttributedString color 부분변경방법
글자의 range만 정해서 색상을 변경하고 싶다면???
let attributedString = NSMutableAttributedString(string: "qwerqweqweqweqwe")
attributedString.addAttribute(NSAttributedString.Key.foregroundColor, value: UIColor(red: 0/255, green: 202/255, blue: 93/255, alpha: 255/255), range: NSRange(location: 0, length: 3))
self.mTvText.attributedText = attributedString
func addAttribute(_ name: NSAttributedString.Key, value: Any, range: NSRange)
key 와 value넣고. range 영역 설정해주면..된다 ..
'ios,swift' 카테고리의 다른 글
[ios] swift uitextview keyboard done (0) | 2020.01.31 |
---|---|
[ios] swift html 적용시키기 (0) | 2020.01.31 |
[ios] swift linker command failed with exit code 1 해결방법 (0) | 2020.01.30 |
[ios] swift html alert 반응 불러오기 (0) | 2020.01.30 |
[ios] swift String trim방법 (0) | 2020.01.30 |