Author Topic: Finding "actual" size of a UILabel  (Read 2605 times)

casimps1

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 2
    • View Profile
Finding "actual" size of a UILabel
« on: March 21, 2014, 11:43:25 PM »
I have a UILabel set with a maximum width. I'd like to find out, after assigning text, what the bounds of the actual rendered text is. In other words, if I assign the text "x" to the UILabel, I'd like a small Bounds returned showing how much space the "x" takes up. If I assign the text "hello hello hello" to the UILabel, I'd like a much larger Bounds returned. UILabel.CalculateBounds() seems to just return the maximum bounding box regardless of the UILabel's content.

Is it possible to get the bounds actually used by text in a UILabel?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Finding "actual" size of a UILabel
« Reply #1 on: March 22, 2014, 02:48:35 PM »
label.UpdateNGUIText();
Vector2 size = NGUIText.CalculatePrintedSize(...);