How would I set the font size of text in a UITextView such that it fills the entire UITextView? I\'d like the user to type in their text, then have the text fill the entire
An updated version of @Arie Litovsky's code. This works in iOS7 and later and stretches the font size both up and down so the text fits.
- (void) stretchFontToFit:(UITextView*)textView
{
while( textView.contentSize.height < textView.frame.size.height )
{
textView.font = [textView.font fontWithSize:textView.font.pointSize +1];
[textView layoutIfNeeded];
}
while( textView.contentSize.height > textView.frame.size.height )
{
textView.font = [textView.font fontWithSize:textView.font.pointSize -1];
[textView layoutIfNeeded];
}
}