tags:

views:

59

answers:

2

Hi,

I'd like to format text in my application's UITableView, like Apple did in the iPhone's Contact application.

Basically last name is bold, and first name is not.

Is there a clean and simple way of accomplishing this?

+2  A: 

Add separate UILabels to your cell's contentView, and format the text in each one of them accordingly.

luvieere
Small correction: Add separate UILabels to your cell's contentview and format accordingly.
marcc
Edited, thanks!
luvieere
This what I have been considering. But it seemed to have a certain "code smell" to it since it would mean I would have to calculate where to place the last name label in relation to the first name label. That just seems messy and wrong to me, but I'll do it if nothing better is proposed. THANKS!
CJCraft.com
There's no "code smell" as this is how Apple does different styles of cells.
Alex Reynolds
A: 

You could add a subclassed UIView to your cell, or just use the subclassed cell, and in drawRect, go ahead and draw your text with all the formatting you require. Again, you will have to calculate where the first and last name go in relation to each other.

mahboudz