5

我正在创建一个 CCLabelTTF 而不指定大小。initWithString:fontName:fontSize:将尺寸设置为 CGSizeZero,以便自动确定尺寸以适合指定的文本。

但是,我想稍后找出最终的大小。我对宽度最感兴趣。

如何确定标签的实际尺寸?

4

1 回答 1

6

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)
于 2012-06-12T21:59:36.183 回答