I using below code in my application to get dynamic height for UILabel.
CGSize maximumLabelSize = CGSizeMake(231, FLT_MAX);
CGSize expectedLabelSize = [labelString
sizeWithFont:self.verbLabel.font
constrainedToSize:maximumLabelSize
lineBreakMode:self.verbLabel.lineBreakMode];
//adjust the label the the new height.
CGRect newFrame = self.verbLabel.frame;
newFrame.size.height = expectedLabelSize.height;
self.verbLabel.frame = newFrame;
return newFrame;
My labelString is What if you asked a controversial public figure? What ideas might he/she suggest? So sometimes I'm able to show this whole string but sometimes it just cut the some text. How can I solve this ... please help me and let me know If am doing something wrong.
Set numberOfLines to 0 to allow for any number of lines.
label.numberOfLines = 0;