-
Notifications
You must be signed in to change notification settings - Fork 420
CALabel
Label text class that is used to display text.
CAView
Access modifier |
Attribute name |
description |
protected |
Text |
Label’s text content |
protected |
fontName |
Label’s font |
protected |
fontSize |
Label’s font size |
protected |
Color |
Label’s font color |
protected |
VerticalTextAlignmet |
Text’s vertical alignment mode |
protected |
TextAlignment |
Text’s horizontal alignment mode |
protected |
NumberOfLine |
Label’s number of line |
Access modifier |
Method name |
Description |
Public |
createWithFrame |
Build a label |
Public |
createWithCenter |
Build a label |
Text
Type: string
Description: label’s text content
fontName
Type: string
Description: label’s font
fontSize
Type: usigned int
Description: font size
Color
Type: ccColor4B
Description: font color
VerticalTextAlignmet
Type: CAVerticalTextAlignment
Description: text’s vertical alignment mode, enumeration type.
1 2 3 4 5 6 |
typedef enum { CAVerticalTextAlignmentTop, CAVerticalTextAlignmentCenter, CAVerticalTextAlignmentBottom, } CAVerticalTextAlignment; |
First type is vertical alignment at the top, second type is vertical alignment at the center, and third type is vertical alignment at the bottom.
TextAlignment
Type: CATextAlignment
Description: text’s horizontal alignment mode, enumeration type.
1 2 3 4 5 6 |
typedef enum { CATextAlignmentLeft, CATextAlignmentCenter, CATextAlignmentRight, } CATextAlignment; |
First type is horizontal alignment at the left, second type is horizontal alignment at the center, and third type is horizontal alignment at the right.
Example:
1 2 3 4 5 6 7 |
CALabel* c_Label = CALabel::createWithCenter(CCRect(size.width*0.5,size.height*0.5,220,500)); c_Label->setText("CrossApp is a cross platform application engine,developed by 9miao.com"); c_Label->setTextAlignment(CATextAlignmentCenter); c_Label->setColor(CAColor_orange); c_Label->setFontSize(28); this->getView()->addSubview(c_Label); |
NumberOfLine
Type: unsigned int
Description: text’s number of line
Example:
static CALabel createWithFrame(const CCRect& rect)*
Return value: CALabel*
Description: build a label and appoint frame.
static CALabel createWithCenter(const CCRect& rect)*
Return value: CALabel*
Description: build a label and appoint center.