I am using the this method for getting the height of the UILabel Dynamically:
+(CGSize) GetSizeOfLabelForGivenText:(UILabel*)label Font:(UIFont*)fontForLabel Size: (CGSize)LabelSize{
label.numberOfLines = 0;
CGSize labelSize = [label.text sizeWithFont:fontForLabel constrainedToSize:LabelSize lineBreakMode:NSLineBreakByCharWrapping];
return (labelSize);
}
With this solution I am getting the exact size of UILabel if my code is running on below iOS 8 but if I run my application on iOS7 then it is returns a different value.
The method
sizeWithFont:constrainedToSize:lineBreakMode:
is deprecated in iOS7. You should usesizeWithAttributes:
instead.Example: