Been poking around but haven’t been able to find an answer here:
Is there a simple way to calculate/view how many lines of text will result from using NSString’s drawInRect method (in a subclassed UIView’s drawRect method).
e.g. in the following snippet:
[self.text drawInRect:titleRect withFont:[UIFont systemFontOfSize:15.] lineBreakMode:UILineBreakModeWordWrap alignment:UITextAlignmentCenter];
How would I calculate how many lines of text are going to result here?
Thanks!
Use the
NSString sizeWithFont:constrainedToSize:lineBreakMode:method to determine the size. The CGSize you pass in should have the desired width and a really high value for the height.