Tasharen Entertainment Forum

Support => NGUI 3 Support => Topic started by: loop on June 03, 2013, 04:12:59 PM

Title: UI Label line count
Post by: loop 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!
Title: Re: UI Label line count
Post by: galuodo 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)
Title: Re: UI Label line count
Post by: eddieB on June 04, 2013, 12:03:33 AM
in my case i look at the relativeSize.y the y return the number of line
Title: Re: UI Label line count
Post by: loop on June 04, 2013, 11:02:34 AM
Thanks eddieB relativeSize.y works :-)
Title: Re: UI Label line count
Post by: ankit khetrapal 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 ?
Title: Re: UI Label line count
Post by: ArenMook on July 19, 2013, 07:04:08 PM
Just count instances of '\n' in the UILabel.processedText