AAV
AAV

Reputation: 3803

How to change color of a word in 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.

Upvotes: 1

Views: 1279

Answers (2)

AAV
AAV

Reputation: 3803

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

Upvotes: 0

typeoneerror
typeoneerror

Reputation: 56948

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.

Upvotes: 2

Related Questions