Author Topic: Limit LabelWidth + replace exceeded char with "..."  (Read 1578 times)

xikky

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 1
  • Posts: 46
    • View Profile
Limit LabelWidth + replace exceeded char with "..."
« on: July 20, 2013, 04:50:42 AM »
Sorry for the simple question, but I want to limit a label to a certain size and if the string exceeds the limited size I would like to add a "..." at the end of the string. I know that to limit a label size I just have to set MaxWidth in the inspector, but how would I know that the limited size is exceeded to replace the exceeding characters and add the "..." to the Label.text?

Thank you!

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Limit LabelWidth + replace exceeded char with "..."
« Reply #1 on: July 20, 2013, 03:03:35 PM »
You would need to compare UIFont.CalculatePrintedSize(original text) to UIFont.CalculatePrintedSize(uiLabel.processedText).