tags:

views:

863

answers:

3

Is is possible to create multi-colored text within a UILabel? I.e, if my text was:

"The quick brown fox"

have the q and b in blue with the rest of the text in black?

I get the feeling I'd have to use a UIWebView and render the text in HTML to accomplish this. Thoughts?

+3  A: 

You are correct that you need to use a UIWebView. Alternatively, you can draw the text yourself into a custom view, but that would probably be a lot more difficult to implement.

If you are going to draw it yourself, you'll want to use the drawing methods in NSString UIKit Additions along with the -[UIColor set] method etc.

Daniel Dickison
+1  A: 

Rendering the text using HTML in a UIWebView is the recommended method from apple.

Dan Lorenc
A: 

Another solution is to concatenate an array of UILabels each with their own individual settings (such as text colour). In your case the label would be broken into labels as [The ][q][uick ][b][rown fox].

SpecialK
@titaniumdecoy: Can you expand on that?
SpecialK