-
Notifications
You must be signed in to change notification settings - Fork 421
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 |
Protected |
LabelSize |
Label’s current size |
Access Modifier |
Method Name |
Description |
Public |
visit |
|
Public |
sizeToFit |
|
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:
LabelSize
Type: CAsize
Description: read-only property, label’s current size, it’s a change value.
virtual void visit()
Return value: void
Description: update label
void sizeToFit()
Return value: void
Description: set self-adaptive label width, namely label width changes with text changes.