0

I have a fixed-size UILabel and/or UITextView and I need to fit variable, multiline text in these views.

I don't want to resize the views, but rather the text. So that, regardless of my text being 1 line or 12 lines, it still always fits in the fixed-size view.

How would I go about this?

I'd think there would be an answer to this somewhere, but so far I always run into the opposite of my question, or I run into replies suggesting autoresize, sizeToFit or sizeWithFont: and neither seem to solve the problem.

1 Answer 1

0

check out UIKit's NSString additions, in particular sizeWithFont:constrainedToSize:

You could use a "for" loop that increases the size of the UIFont until the size exceeds the UILabel or UITextView.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.