2

Given a layout that you set up using constraints, how do you find the biggest text size that fits your labels and buttons?

You can use adjustsFontSizeToFitWidth for labels but it only cares about width, not height. And I don't understand how button labels exactly work...

I posted an answer to a related question, but I wanted to ask it again since the other question is a bit forgotten and I don't know how I would do it for buttons.

Community
  • 1
  • 1
Ferran Maylinch
  • 10,919
  • 16
  • 85
  • 100
  • Is there no such property as ```adjustsFontSizeToFitHeight```? –  Jun 04 '15 at 14:52
  • This post may be of some use to you - http://stackoverflow.com/questions/7242608/resize-uilabel-based-on-content –  Jun 04 '15 at 14:53
  • There's no `adjustsFontSizeToFitHeight`. And the post you mention is not what I'm looking for. Thanks anyway. – Ferran Maylinch Jun 04 '15 at 14:58
  • 1
    I think the only way to do this is to use something like `sizeWithAttributes:` in a loop where you increase the font size each time through the loop until the size returned is bigger than your label or button (allowing for whatever padding there is in those views). There is no way to do this with auto layout if your goal is to actually find the font size (you can auto-shrink the text to fit though). – rdelmar Jun 04 '15 at 18:12

0 Answers0