Class ccui.Text
- Defined in: UIText.js
- Extends ccui.Widget
Constructor Attributes | Constructor Name and Description |
---|---|
The text control of Cocos UI.
|
Method Summary
Class Detail
ccui.Text()
The text control of Cocos UI.
Field Detail
{Number}
boundingHeight
- Height of the bounding area of label, the real content height is limited by boundingHeight
{Number}
boundingWidth
- Width of the bounding area of label, the real content width is limited by boundingWidth
{String}
font
- The label font with a style string: e.g. "18px Verdana"
{String}
fontName
- The label font name
{Number}
fontSize
- The label font size
<static> <constant>
ccui.Text.RENDERER_ZORDER
The zOrder value of ccui.Text's renderer.
{String}
string
- The content string of the label
{Number}
stringLength
- <@readonly> The content string length of the label
{Number}
textAlign
- Horizontal Alignment of label, cc.TEXT_ALIGNMENT_LEFT|cc.TEXT_ALIGNMENT_CENTER|cc.TEXT_ALIGNMENT_RIGHT
{Boolean}
touchScaleEnabled
- Indicate whether the label will scale when touching
{Number}
verticalAlign
- Vertical Alignment of label: cc.VERTICAL_TEXT_ALIGNMENT_TOP|cc.VERTICAL_TEXT_ALIGNMENT_CENTER|cc.VERTICAL_TEXT_ALIGNMENT_BOTTOM
Method Detail
-
ctor(textContent, fontName, fontSize)allocates and initializes a UILabel. Constructor of ccui.Text. override it to extend the construction behavior, remember to call "this._super()" in the extended "ctor" function.
// example var uiLabel = new ccui.Text();
- Parameters:
- {String} textContent
- {String} fontName
- {Number} fontSize
-
disableEffect()Disables renderer's effect.
-
enableGlow(glowColor)Enables glow color
- Parameters:
- glowColor
-
enableOutline(outlineColor, outlineSize)Enables outline style and sets outline's color and size.
-
enableShadow(shadowColor, offset, blurRadius)Enables shadow style and sets color, offset and blur radius styles.
-
{string} getDescription()Returns the "class name" of ccui.Text.
- Returns:
- {string}
-
{string} getFontName()Returns font name of ccui.Text.
- Returns:
- {string}
-
{Number} getFontSize()Returns font Size of ccui.Text
- Returns:
- {Number}
-
{String} getString()Gets the string value of ccui.Text.
- Returns:
- {String}
-
{Number} getStringLength()Gets the string length of ccui.Text.
- Returns:
- {Number}
-
{String} getStringValue()Gets the string value of ccui.Text.
- Deprecated:
- since v3.0, please use getString instead.
- Returns:
- {String}
-
{cc.Size} getTextAreaSize()Returns renderer's dimension.
- Returns:
- {cc.Size}
-
{TEXT_ALIGNMENT_LEFT|TEXT_ALIGNMENT_CENTER|TEXT_ALIGNMENT_RIGHT} getTextHorizontalAlignment()Returns Horizontal Alignment of label
- Returns:
- {TEXT_ALIGNMENT_LEFT|TEXT_ALIGNMENT_CENTER|TEXT_ALIGNMENT_RIGHT}
-
{VERTICAL_TEXT_ALIGNMENT_TOP|VERTICAL_TEXT_ALIGNMENT_CENTER|VERTICAL_TEXT_ALIGNMENT_BOTTOM} getTextVerticalAlignment()Gets text vertical alignment.
- Returns:
- {VERTICAL_TEXT_ALIGNMENT_TOP|VERTICAL_TEXT_ALIGNMENT_CENTER|VERTICAL_TEXT_ALIGNMENT_BOTTOM}
-
{null} getType()Returns the type of ccui.Text.
- Returns:
- {null}
-
{cc.Node} getVirtualRenderer()Returns the renderer of ccui.Text.
- Returns:
- {cc.Node}
-
{cc.Size} getVirtualRendererSize()Returns the renderer's content size.
- Returns:
- {cc.Size}
-
{boolean} init(textContent, fontName, fontSize)Initializes a ccui.Text. Please do not call this function by yourself, you should pass the parameters to constructor to initialize it.
- Parameters:
- {String} textContent
- {String} fontName
- {Number} fontSize
- Returns:
- {boolean}
-
{Boolean} isTouchScaleChangeEnabled()Gets the touch scale enabled of label.
- Returns:
- {Boolean}
-
{String} setFontName(name)Sets font name
- Parameters:
- name
- Returns:
- {String} name
-
setFontSize(size)Sets fontSize
- Parameters:
- {Number} size
-
setString(text)Changes the value of ccui.Text.
- Parameters:
- {String} text
-
setText(text)Changes the value of ccui.Text.
- Parameters:
- {String} text
- Deprecated:
- since v3.0, please use setString() instead.
-
setTextAreaSize(size)Sets text Area Size
- Parameters:
- {cc.Size} size
-
setTextHorizontalAlignment(alignment)Sets Horizontal Alignment of cc.LabelTTF
- Parameters:
- {cc.TEXT_ALIGNMENT_LEFT|cc.TEXT_ALIGNMENT_CENTER|cc.TEXT_ALIGNMENT_RIGHT} alignment
- Horizontal Alignment
-
setTextVerticalAlignment(alignment)Sets Vertical Alignment of label
- Parameters:
- {cc.VERTICAL_TEXT_ALIGNMENT_TOP|cc.VERTICAL_TEXT_ALIGNMENT_CENTER|cc.VERTICAL_TEXT_ALIGNMENT_BOTTOM} alignment
-
setTouchScaleChangeEnabled(enable)Sets the touch scale enabled of label.
- Parameters:
- {Boolean} enable