iPhone – How to find height of a label for dynamic string in it.

iPhone – How to find height of a label for dynamic string in it.

Here is a small but very useful function, which gives height of a label for which dynamic string is to be set:

-(NSInteger) findHeightOfLabelString:(NSString *)textString
{
UIFont *font = [UIFont systemFontOfSize:17];
CGSize size = CGSizeMake(175.0f, MAXFLOAT);
CGSize labelSize=[textString sizeWithFont:font constrainedToSize:size lineBreakMode:UILineBreakModeWordWrap];
return labelSize.height;
}

Leave a Reply

Your email address will not be published. Required fields are marked *