Author Topic: UILabel Height  (Read 5248 times)

schwarzenego

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 30
    • View Profile
UILabel Height
« on: February 19, 2014, 01:21:32 PM »
Hello,

In NGUI 2.X I remember using something like label.relativeSize.y and that would return the number of lines of the text, which I could use * the height of each line to get the total height of the text. However, I understand that thats changed, and we should use uilabel.height to get the value in pixels. However, heres the problem:

  1. //initially myLabel.text is something equivalent to 1 line of text
  2. print(myLabel.height); //Output 10 (for example, considering 10 pixels per line)
  3. myLabel.text = "asdasdasdasdassad"; //equivalent to 2 lines of text
  4. print(myLabel.height); //Output 10 again, as if size wasnt updated
  5.  

What I am doing to get the correct value is yield return null, but I would appreciate if I didnt have to wait for a frame and use coroutines for everything. Is it possible to get the updated height immediately?

Thanks for your attention,
Best Regards,
Allan

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UILabel Height
« Reply #1 on: February 19, 2014, 03:50:05 PM »
label.printedSize tells you the final size.

schwarzenego

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 30
    • View Profile
Re: UILabel Height
« Reply #2 on: February 20, 2014, 06:21:35 PM »
Thanks, that worked! =)

Quel

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 11
    • View Profile
Re: UILabel Height
« Reply #3 on: March 10, 2014, 03:39:33 AM »
See ArenMook ?.. This is what I was talking about when I said to you that you must maintain the compatibility with your own previous versions.

This is just another little stone into the shoe.
It was really needed to change that ?. You can't simply keep it as legacy property ?

Sincerly. NGUI is a good asset but you should fix this annoying bad habit.