I am looking for a way to use a UILabel (or something similar) to display something like this:
Tom: Some message.
It is like how it’s done in for example the Facebook app to display the “what’s on your mind?” messages. Does anyone have any suggestions how to approach this?
Use two UILabel IBOutlets, each with a different format (font/color/etc), as you desire.. Move the second one over the first based on where the first one’s text ends. You can get that via sizeWithFont:forWidth:lineBreakMode:
Alternatively, you can subclass UILabel, and draw the text yourself in drawRect. If you do it this way, just add an instance variable to tell you how much of the string to draw in one format, and draw the rest in another.
Update: Please see @Akshay’s response below. As of iOS6 UILabel’s can contain NSMutableAttributedString. When I wrote this, this was not available.