1

I have a situation where I have a UILabel object whose text is all in all lower case.

If use size to fit, it assume the highest Y point of the font and only shrinks it to that.

enter image description here

But if there are no capital letters I need the bounding box to shrink to the exact text size.

Do you know how I can create my own sizing function that returns the true bounds of the text as its rendered (not based on the font max and mins)?

Wain
  • 118,658
  • 15
  • 128
  • 151
Aggressor
  • 13,323
  • 24
  • 103
  • 182
  • Check this answer: http://stackoverflow.com/questions/17328689/vertically-center-text-in-uilabel-depending-on-actual-visible-letter-height – badweasel Jan 02 '15 at 20:17
  • This [answer](http://stackoverflow.com/questions/23075693/contenting-deprecated-sizewithfontconstrainedtosize-to-boundingrectwithsizeopt) can also be helpful. – kedzia Jan 02 '15 at 22:32
  • What I would do is use auto layout and override `intrinsicContentSize`. Figuring out a good size based on the font and contents is up to you. – matt Jan 03 '15 at 02:51

0 Answers0