Skip to content
9miao Mobile Game edited this page Jul 3, 2014 · 2 revisions

CALabel Detailed Description

Class Description

Label text class that is used to display text.

Base Class

CAView

Attribute

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

Method

Access modifier

Method name

Description

Public

createWithFrame

Build a label

Public

createWithCenter

Build a label

Attribute Description

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);

![](http://www.9miao.com/ueditor/php/upload/image/20140623/1403526380597803.png)

NumberOfLine
Type: unsigned int
Description: text’s number of line

Example:

Method Description

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.

Clone this wiki locally