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.
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
You'll need to use NSAttributedString
. I recommend checking out AliSoftware's OHAttributedLabel which extends UILabel and adds support for setting text via NSAttributedString among other helpers. I'm using it in a current project and it's pretty fantastic.
回答2:
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