具有固定宽度的多线标签

时间:2012-07-16 13:58:57

标签: cocos2d-iphone

在iPhone的cocos2d中,如何创建具有固定宽度的多行标签(文本框)?

目前,我正在使用:

CCLabelTTF  *labelTextTop = [CCLabelTTF labelWithString: @"My long string that should be placed in two lines, instead of in one extremely long one."
                                        fontName:        @"Marker Felt" 
                                        fontSize:        40];

1 个答案:

答案 0 :(得分:1)

这是我目前使用的:

CGSize size;
size.width=400;
size.height=110;
sayBubbleTextDisplayed_=[[CCLabelTTF  labelWithString:@"some long and winded blabla "  
                                           dimensions:size 
                                            alignment:UITextAlignmentLeft 
                                        lineBreakMode:UILineBreakModeWordWrap
                                             fontName:@"American Typewriter" 
                                             fontSize:16] retain];