I am trying to find a non-deprecated method to size the font of a textview down so that all text fits in the textview without requiring scrolling.
The method \'sizeWithF
Your problem can be solved by simply replacing sizeWithFont: constrainedToSize:
with :
boundingRectWithSize:CGSizeMake(newView.frame.size.width, FLT_MAX)
options:NSStringDrawingUsesLineFragmentOrigin
attributes:@{NSFontAttributeName:[UIFont fontWithName:@"Interstate" size:fontSize]}
context:nil];
The sizeThatFits
method can be used to address this problem like this:
while (fontSize > minSize && [newView sizeThatFits:(CGSizeMake(newView.frame.size.width, FLT_MAX))].height >= newView.frame.size.height ) {
fontSize -= 1.0;
newView.font = [tv.font fontWithSize:fontSize];
}
I hope one of these solutions solve your problem. Cheers!