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
In viewDidLoad:
textView.textContainer.lineFragmentPadding = 0;
textView.textContainerInset = UIEdgeInsetsMake(0, 0, 0, 0);
You need to add UITextViewDelegate:
- (void)updateTextFont:(UITextView *)textView {
CGSize textViewSize = textView.frame.size;
CGSize sizeOfText = [textView.text sizeWithAttributes:@{NSFontAttributeName: textView.font}];
CGFloat fontOfWidth = floorf(textView.font.pointSize / sizeOfText.height * textViewSize.height);
CGFloat fontOfHeight = floorf(textView.font.pointSize / sizeOfText.width * textViewSize.width);
textView.font = [textView.font fontWithSize:MIN(fontOfHeight, fontOfWidth)];
}