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 UITextView.
Any help is appreciated!
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 UITextView.
Any help is appreciated!
Similar approach to Arie Litovsky's answer but without sub-classing (or use of a category) and not using
contentSize
which didn't return the correct height of the rendered text for me. Tested on iOS 7:The approach is to keep reducing the font size until the text just fits inside the frame of the text view.
If you were going to use this in production you would still need to:
I have converted dementiazz's answer to Swift:
I have converted dementiazz's & Matt Frear's answer to Swift 3:
This property is only available on UITextFields. To do this in a UITextView, you'd have to constantly watch the text and manually adjust the font size as that changed.
I have converted Matt Frear's answer to Swift 4.1 as extension for UITextView:
}
Try this, it's a lot simpler: