Saturday, August 17, 2013

thumbnail

Set UILabel height depending on the text

//Calculate the expected size based on the font and linebreak mode of your label
// FLT_MAX here simply means no constraint in height

CGSize maximumLabelSize = CGSizeMake(296, FLT_MAX);

CGSize expectedLabelSize = [myString sizeWithFont:yourLabel.font constrainedToSize:maximumLabelSize lineBreakMode:yourLabel.lineBreakMode];  

//Set the label the the new height.
CGRect newFrame = myLabel.frame;
newFrame.size.height = expectedLabelSize.height;
yourLabel.frame = newFrame;

Subscribe by Email

Follow Updates Articles from This Blog via Email

No Comments

comments

About me

simple one.