如何在UITextView中更改单词的颜色? [英] How to change color of a word in UITextView?

查看:91
本文介绍了如何在UITextView中更改单词的颜色?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以在特定范围或特定单词中更改UITextView的颜色?如果一个单词在视图中出现多次,请更改该单词的颜色.

Is it possible to change UITextView`s color in particular range or particular word? If a word appear more than once in a view then change the color of that word.

推荐答案

我解决了这个问题.我创建了UILable和UITextView的子类,并使用核心文本(CATextLayer)作为label/textview上的一层,并且NSAttributedString将存储有关字体和颜色的所有信息

I solve the problem. I created subclass of UILable and UITextView used core text (CATextLayer) as a layer on label/textview and NSAttributedString will store all the information about the font and color

这篇关于如何在UITextView中更改单词的颜色?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆