I have a UILabel that is correctly word wrapping if I force its frame height to be tall enough. However, I want it to dynamically find the proper height, and the sizeWithFont method isn’t doing this; that method just creates a single line in my label:
CGSize subtitleSize=[subtitle sizeWithFont:subtitleFont forWidth:maxwidth lineBreakMode:UILineBreakModeWordWrap];
Then I use the same text, font and size from this function:
UILabel *subLabel=[[[UILabel alloc] initWithFrame:CGRectMake(0, 0, maxwidth, subtitleSize.height)]autorelease];
subLabel.font=subtitleFont;
subLabel.text=subtitle;
subLabel.numberOfLines=0;
subLabel.lineBreakMode=UILineBreakModeWordWrap;
It looks like it should all work and give me a size which i then use. But the height of the size is always just one line for the label.
you may use this
max the size in constrainedToSize