Author Topic: UI Label line count  (Read 6263 times)

loop

  • Guest
UI Label line count
« on: June 03, 2013, 04:12:59 PM »
Hello!

I need the current line count of a label(with a max width). I tried (int)UIFont.CalculatePrintedSize(text).y; but y is always one, even though the label has two lines. I'm using NGUI 2.6.1e.

Thanks for help!

galuodo

  • Jr. Member
  • **
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 65
    • View Profile
Re: UI Label line count
« Reply #1 on: June 03, 2013, 09:02:39 PM »
CalculatePrintedSize return the size of the text, and you should multiply the size of the font to get the how much pixels does it takes. like (int)(UIFont.CalculatePrintedSize(text).y* font.size)

eddieB

  • Guest
Re: UI Label line count
« Reply #2 on: June 04, 2013, 12:03:33 AM »
in my case i look at the relativeSize.y the y return the number of line

loop

  • Guest
Re: UI Label line count
« Reply #3 on: June 04, 2013, 11:02:34 AM »
Thanks eddieB relativeSize.y works :-)

ankit khetrapal

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 16
    • View Profile
Re: UI Label line count
« Reply #4 on: July 19, 2013, 08:20:31 AM »
how can i get the total number of lines which will be required to show the label if it is limited with max line count.

i will try and explain this more suppose i have a label which has suppose 40 lines, now to make label look small i set the Max Line var for this label to lets say 5.

So now only 5 lines are visible, now i add a see more button, on clicking which the label should get bigger and show all the lines.

How can this be achieved ?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UI Label line count
« Reply #5 on: July 19, 2013, 07:04:08 PM »
Just count instances of '\n' in the UILabel.processedText