ioscocos2d-iphonecclabelttf

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? because I have a number that increment and if it gets too big collides with a close image...


Solution

  • in cocos2d version 3.x, you can

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

    ... not tested, just from memory.