Author Topic: UILabel line count  (Read 4853 times)

rain

  • Jr. Member
  • **
  • Thank You
  • -Given: 2
  • -Receive: 4
  • Posts: 79
    • View Profile
UILabel line count
« on: September 21, 2012, 09:39:20 AM »
Hi!

The question is simple: how do I count how many lines does a UILabel have?

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: UILabel line count
« Reply #1 on: September 21, 2012, 10:45:15 AM »
(int)UIFont.CalculatePrintedSize(text).y;

rain

  • Jr. Member
  • **
  • Thank You
  • -Given: 2
  • -Receive: 4
  • Posts: 79
    • View Profile
Re: UILabel line count
« Reply #2 on: September 21, 2012, 10:50:21 AM »
You are my hero

PabloAM

  • Jr. Member
  • **
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 58
    • View Profile
Re: UILabel line count
« Reply #3 on: July 11, 2013, 05:22:15 AM »
This does not works for the new version 2.6.2.

How could I know the lines of an UILabel??

Update:
I´ve got the number of lines with this:
(int)dialog.font.CalculatePrintedSize(dialog.text,true,UIFont.SymbolStyle.None).y;

But with this text:
dialog.text = "SD AD SA DSADSADSAD HOLA sfdsf sdf sd fsdfsdjs dhfsdkjhfsdj khfkjsdhf jskdhf sdhfsdkfhsdkj fjksd fhjsd hfj sdhfjsdkfhsdjf ";

I got 1, when should be 3 as you can see on the screenshot attached.

   
I don´t know what it is :S

Update 2:


FIXED! :)

(int)dialog.font.CalculatePrintedSize(dialog.processedText,true,UIFont.SymbolStyle.None).y;


Thanks anyways ! xD
« Last Edit: July 11, 2013, 06:02:35 AM by PabloAM »