AutoLua2AutoLua2
  • 快速开始
  • 介绍
  • 自动化API

    • 图色相关
    • 模拟相关
    • 节点相关
    • 界面相关
    • 其他
  • 界面API
  • 快速开始
  • 介绍
  • 自动化API

    • 图色相关
    • 模拟相关
    • 节点相关
    • 界面相关
    • 其他
  • 界面API
  • 自动化API

    • 图色相关

      • 全局
      • Bitmap
      • FindOrder
    • 模拟相关

      • 全局
      • Pointer
      • KeyCode
    • 节点相关

      • 全局
      • UiObject
      • UiSelector
    • 交互相关

      • 全局
      • UI
      • FloatView
      • FloatController
      • LayoutParams
      • LayoutParamsFlag
    • 其他
  • UI的API

    • 全局变量
    • 视图

      • View 类
      • window 类
      • Label 类
      • ImageButton 类
      • EditTextView 类
      • ScrollView 类
      • LinearLayout 类
      • Alert 类
      • Toast 类
      • Dialog 类
      • Switch 类
      • TabSegmentView 类
      • TableView 类
      • TableViewAdapter 类
      • TableViewAutoFitAdapter 类
      • CollectionView 类
      • CollectionViewAdapter 类
      • CollectionViewAutoFitAdapter 类
      • CollectionViewLayout 类
      • WaterfallView 类
      • WaterfallAdapter 类
      • WaterfallLayout 类
      • ViewPager 类
      • ViewPagerAdapter 类
    • 动画
    • 数据

      • Map 类
      • Array 类
      • Point 类
      • Size 类
      • Rect 类
      • Color 类
      • StyleString 类
    • 工具

      • Loading 类
      • Http 类
      • System 类
      • Timer 类
      • MBit 类
      • File 类
      • Application 类
      • Navigator 类
      • PreferenceUtils 类
      • TypeUtils 类
      • StringUtil 类
      • NetworkReachability 类
      • GlobalEvent 类
      • Clipboard 类
      • CornerManager 类
    • 枚举

      • ContentMode 枚举
      • TextAlign 枚举
      • BreakMode 枚举
      • FontStyle 枚举
      • UnderlineStyle 枚举
      • RepeatType 枚举
      • InterpolatorType 枚举
      • AnimType 枚举
      • EditTextViewInputMode 枚举
      • ReturnType 枚举
      • ScrollDirection 枚举
      • StatusBarStyle 枚举
      • RectCorner 枚举
      • LinearType 枚举
      • Gravity 枚举
      • MeasurementType 枚举
      • ValueType 枚举
      • GradientType 枚举
      • TabSegmentAlignment 枚举
      • NetworkState 枚举
      • CachePolicy 枚举
      • ResponseKey 枚举
      • ErrorKey 枚举
      • EncType 枚举

Label 类

继承 View

文本展示控件

@note 非容器视图,不可以添加子视图。 注意:由于iOS Label在固定高度情况下渲染空间不足时,不会渲染剩下的行数,Android会继续渲染并存在截断现象,故,如果出现iOS和Android行数不一致情况,请将高度设置为能够容下足够行数的高度

变量

_priveta_class_name : string

name : string

方法

text

设置文本内容

参数

  • content : string 要展示的文本内容

返回值

  • : Label

text

获取当前文本内容

返回值

  • : string

textAlign

设置文字对齐方式,参见TextAlign

参数

  • align : TextAlign 文字对齐方式

返回值

  • : Label

textAlign

获取文字对齐方式,参见TextAlign

返回值

  • 文字对齐方式,参见 : TextAlign TextAlign](TextAlign)

fontSize

设置字体大小

参数

  • size : number 文字大小

返回值

  • : Label

fontSize

获取字体大小

返回值

  • : number

textColor

设置文字颜色

参数

  • color : Color 文字颜色, 见Color

返回值

  • : Label

textColor

获取文字颜色

返回值

  • 文字颜色 : Color Color](Color)

lines

设置展示的最大行数,默认只展示一行

@note 0代表最大行数不限制。当lines传入0时,Label的BreakMode会强制改为Clipping切割模式

参数

  • num : number 最大行数

返回值

  • : Label

lines

获取展示的最大行数

返回值

  • : number

breakMode

设置文字截断样式,参见BreakMode的枚举值

@note 在多行情况下,当设置Start或Middle时,会强制改为Clipping切割模式

参数

  • mode : BreakMode 文字截断样式的枚举值

返回值

  • : Label

breakMode

获取文字截断样式,参见BreakMode的枚举值

返回值

  • : BreakMode

styleText

设置富文本,详情参见StyleString

@note iOS设置该属性会清空之前设置的属性

参数

  • styleString : StyleString 富文本

返回值

  • : Label

styleText

获取富文本,详情参见StyleString

返回值

  • : StyleString

setTextBold

设置文字粗体

@note 弃用, 请使用setTextFontStyle方法

返回值

  • : Label

setTextFontStyle

设置字体样式

参数

  • style : FontStyle 字体样式枚举

返回值

  • : Label

fontNameSize

设置自定义字体

参数

  • name : string 字体名称
  • size : number 字体大小

返回值

  • : Label

setAutoFit

是否使用文本自适应

@note 该已弃用,请使用新布局的WrapContent

参数

  • isFit : boolean 是否使用文本自适应,true为自适应,false为不自适应,默认false

返回值

  • : Label

setWrapContent

包裹内容,即大小按照文本内容自适应, setWrapContent(true)与width(MeasurementType.WRAP_CONTENT) && height(MeasurementType.WRAP_CONTENT)等效

@note 当label同时设置setWrapContent方法及width(10):height(10)的情况下,展示效果取决于设置的先后顺序。如:当label设置了setWrapContent(true)之后设置width(10):height(10),label宽度为10、高度为10;当设置width(10):height(10)固定宽高后设置WrapContent,即以setWrapContent设置为准

参数

  • isWrap : boolean true为自适应,false为不自适应,默认true

返回值

  • : Label

setLineSpacing

设置多行文本之间行间距

参数

  • spacing : number 行间的距离

返回值

  • : Label

a_setIncludeFontPadding

设置是否在文字上面和下面添加一点额外的padding

@note 仅android有效,ios空实现

参数

  • bool : boolean 默认为false

返回值

  • : Label
Prev
window 类
Next
ImageButton 类