Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

admanimal

macrumors 68040
Original poster
Apr 22, 2005
3,531
2
Has anyone figured out how to get the auto font size adjustment to work for a UILabel when it has numberOfLines set to more than one? It seems to just ignore adjustFontSizeToFitWidth if the label has more than one line.
 

siva.d

macrumors newbie
Sep 30, 2008
13
0
Hyderabad,India
I also need this can any one help

Thanks in advance,

I want to display text in more than one line, can any one help me.

Thank you
siva.d
 

PhoneyDeveloper

macrumors 68040
Sep 2, 2008
3,114
93
Did you read the comment in UILabel.h where it says that adjustsFontSizeToFitWidth only works if lineCount is 1?
 

Niiro13

macrumors 68000
Feb 12, 2008
1,719
0
Illinois
So in other words, you'll have to use a UITextView which has a dynamic number of lines but fixed font size.
 

PhoneyDeveloper

macrumors 68040
Sep 2, 2008
3,114
93
Dynamic number of lines with a fixed font size is exactly what UILabel gives you if you set the numberOfLines to zero. The usual reason to use adjustsFontSizeToFitWidth is if you have a fixed size for the label and you want all the text to fit. If you can allow the label to be any height then you don't need that.

Also you could probably use sizeWithFont:constrainedToSize:lineBreakMode to find the font size that will show all the text in a multiline label and then set that font size for the label.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.