views:

36

answers:

2

For an application I'm building, I dynamically add text to a label. The first part of the label's text has to be black so I choose that color in Interface Builder. However the second part (the first part is a title second part a description) has to be darkgray.

Oh and note: 2 labels is not an option because of positioning.

A: 

There is no direct API to do that, however it's easy to subclass UIView class and use drawRect method to draw the strings by yourself using CGContextSetRGBFillColor to set the color and NSString's drawInRect: method to draw portions of text in specified rectangles

Alexander Voloshyn
Thanks I'll try that!
Lewion
A: 

Or you could use a UIWebView to Format and color the text. ;-)

Sandro Meier