I displayed the text in UILabel by using wrap method. Now I want to need to find the how many number of line is there in UILabel.
If there is any possible way to fi
The method -sizeWithFont:constrainedToSize:lineBreakMode is now deprecated. You will want to use the method -boundingRectWithSize:options:attributes:context: now.
Here's an examples:
CGSize boundingRectSize = CGSizeMake(widthToConstrainTo, CGFLOAT_MAX);
NSDictionary *attributes = @{NSFontAttributeName : [UIFont fontWithName:fontName size:14]};
CGRect labelSize = [labelString boundingRectWithSize:boundingRectSize options:NSStringDrawingUsesLineFragmentOrigin | NSStringDrawingUsesFontLeading
attributes:attributes
context:nil];
In the above example I know the width I want to constrain the label to but since I'm not sure of the height, I just max the height param out using CGFLOAT_MAX. For the options you need to use NSStringDrawingUsesLineFragmentOrigin and NSStringDrawingUsesFontLeading if you're trying to calculate the size a label that can be any number of lines.