I'm creating a CCLabelTTF without specifying a size. initWithString:fontName:fontSize: sets the dimensions to CGSizeZero so that the size will be determined automatically to fit the specified text.
However, I'd like to find out later what the size ended up being. I'm most interested in the width.
How can I determine the label's actual size?
There are two properties you can look at in the texture, which gets updated every time you set a new string or change font-size, etc.
yourTTFLabel.texture.contentSizeInPixels
or
yourTTFLabel.texture.contentSize
(in points)If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With