Author Topic: Properly set the UILabel width.  (Read 2594 times)

Quel

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 11
    • View Profile
Properly set the UILabel width.
« on: June 18, 2015, 03:09:55 AM »
Hi. I have "elementary" problem here that I can't fix.

- I use a box(UISprite) with a variable width.
- Into the box there are a variable text(UILabel).
- The text it's horizontally anchored to box, so it supposed to it should adjust to available box width.
- I set new width to the box.
- I set new text value to de Label.
- Text anchoring method don't notice correctly the box size, so it does wrong.
- So when I try to read the text height, it returns a bad value.

How can I solve it ?.

PD: I have already try it using ALL possible methods into UILabel/UISprite class: UpdateAnchors, ResetAndUpdateAnchors, CalculateBounds, ProssesText, UpdateNGUIText, MarkAsChanged, Update, ...

Quel

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 11
    • View Profile
Re: Properly set the UILabel width.
« Reply #1 on: June 18, 2015, 04:58:07 AM »
At last. After testing a lot of random combinations of methods, I found one that "works".

  1. myLabel.text = "bla bla bla bla bla bla bla bla bla bla bla";
  2.  
  3. myLabel.Update();
  4. myLabel.ProcessText();