tags:

views:

57

answers:

2

Hi,

how can i have a UILabel with two different colors for the font. I will have text in two different strings and i want to make text with first string as red and second as green. The length of both the string is variable.

Thanks in advance

+2  A: 

UILabel can only have one color. You either need a more sophisticated element, or - probably easier - just use two separate labels. Use [yourLabel sizeToFit]; and place them accordingly.

Eiko
okkk i will try to explore sizeToFit property of uilabel, thanks for replying
pankaj
A: 

I had to do that too in a project. I used this class from another post but it's only for one single line, I don't know if it is enough for you.

iPhone - UILabel containing text with multiple fonts at the same time

William Remacle