CGRect - boundingrectwithsize for long NSString not working

381 views Asked by At

I have this method that returns the height of NSString and returns the height on tableview method : heightForRowAtIndexPath but when the NSString gets longer than maybe 2 paragraphs a small section at the end of the string gets cut off.

- (float)heightWithFont:(UIFont *)font width:(float)width {    
CGRect frame = [string boundingRectWithSize:CGSizeMake(width, 9999.f)
                                  options:(NSStringDrawingUsesLineFragmentOrigin | NSStringDrawingUsesFontLeading)
                               attributes:@{ NSFontAttributeName: font}
                                  context:nil];
return frame.size.height; }
0

There are 0 answers