Sizing CCLabelTTF

I am creating CCLabelTTF without specifying size. initWithString: fontName: fontSize: sets the dimensions in CGSizeZero so that the size is determined automatically to match the specified text.

However, I would like to find out later what size appeared. I'm most interested in width.

How to determine the actual label size?

+5
source share
1 answer

There are two properties that you can see in the texture, which is updated every time you set a new line or change the font size, etc.

  • yourTTFLabel.texture.contentSizeInPixels

or

  • yourTTFLabel.texture.contentSize (in points)
+6
source

All Articles