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?
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.
Rendering the text using HTML in a UIWebView is the recommended method from apple.
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].
CoreText
can be successfully used in many applications.
We can do it using CoreText Framework,You can study further more using this link CoreText Tutorial for iOS
来源:https://stackoverflow.com/questions/976799/multi-colored-uilabel-text