问题
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
来源:https://stackoverflow.com/questions/7447466/how-to-change-color-of-a-word-in-uitextview