简体   繁体   English

CCLabelTTF自动设置字体大小

[英]CCLabelTTF set automatically the font size

Is there a way to set automatically the font size of a CCLabelTTF text in base of the length of the string? 有没有一种方法可以根据字符串的长度自动设置CCLabelTTF文本的字体大小? because I have a number that increment and if it gets too big collides with a close image... 因为我有一个递增的数字,如果数字太大,就会与接近的图像碰撞...

in cocos2d version 3.x, you can 在cocos2d 3.x版中,您可以

CCLabelTTF *label = [CCLabelTTF whatever ....];
label.dimensions = CGSizeMake(widthYouWant,heightYouWant);
label.adjustFontSizeToFit = YES;
label.minimumFontSize = 8;

... not tested, just from memory. ...未经测试,仅从内存中进行。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM