Author Topic: Getting real font size of a shrunk UILabel  (Read 1866 times)

Camille

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 4
    • View Profile
Getting real font size of a shrunk UILabel
« on: August 28, 2014, 09:37:58 PM »
Hi there

I have a set of buttons with UILabels inside them as children. These UILabels were set to ShrinkContent so that the text is always there when the buttons resized.

However, some buttons' texts are longer than others - e.g. "Attachments", "Notes". "Attachments" will get shrunk first because it is longer. I would like the "Notes" text to be shown at the same font size as the Attachments one so that the font size is always the same for all those buttons.

So what I did is I wrote a script to set the "Notes" font size to be the same as "Attachments" font size - but this does not work because "Attachments" is shrunk and the actual shown size does not match the font size.

How can I get access to the font size that is actually displayed when a UILabel is shrunk?

Thanks

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Getting real font size of a shrunk UILabel
« Reply #1 on: August 28, 2014, 09:40:24 PM »
You can adjust the size of the label manually. See what kind of size you need to not having it be shrunk on one, and set the other one to match. If you need to know the printed size of the label, UILabel.printedSize.