João Colaço
João Colaço

Reputation: 1301

Resize font size with a change in height by autolayout on a textfield

I have a UITextField that can be resized with autolayout. How can I make the font size automatically smaller when the textfield height gets smaller than the font?

Thanks

Upvotes: 1

Views: 1713

Answers (1)

user1285464
user1285464

Reputation:

I wish I could figure out how to leave comments like other's do, without making it an answer.

Anyway, this seems to be something pretty fundamental to the design of iOS, there just does not seem to be any acknowledgment of this kind of thing, the entire design of the libraries/objects/properties seems to think you'd only ever want to change the font size, based on the width, but this seems entirely arbitrary to me. With auto layout, it seems like just an unfortunate carry over from springs and struts that needs to be fixed.

As a work-around, you could create some constraints to link the width of the label to the height, by some proportion, so that the height change caused the width to also change, and thus force the font to change.

I am trying to solve the same problem.

These constraints will have to be created in code, as far as I can tell.

Upvotes: 1

Related Questions