Reputation: 1892
I have a need to set the contentSize of a non-scrolling UITextView exactly to it's superview's frame. I need to do this for the purpose of getting the range of characters that fit, and while I know there's better methods for doing this, or even better views to be using, I need to use this custom UITextView for it's specific capabilities. Simply doing:
textView?.contentSize = superView.frame.size
doesn't seem to set anything, and it's contentSize is still as long as it's content. I want to simply truncate the content at where it just wont fit anymore. I'm on Swift 3 and xCode 8 if that makes a difference.
Upvotes: 0
Views: 365
Reputation: 1892
Figured it out. Scrolling was enabled. Disabling scrolling seems to have fixed it.
Upvotes: 0
Reputation: 23
You can do so using .bounds
:
textView?.bounds = superView.bounds
That should set all the properties you want to be the same as the super view.
Upvotes: 1