Skip to content

UITextLabel

继承自

描述

一个text文本组件

属性

ColorQuadTitleColor
字体颜色
TextVAlignmentTextVAlignment
上下对齐,有向上、中间和向下对齐
TextHAlignmentTextHAlignment
左右对齐,有向左、中间和向右对齐
intFontSize
字体大小
stringTitle
文本内容
AutoSizeTypeIsAutoSize
自动调整节点大小为字体大小
boolOutlineEnable
是否显示边框
ColorQuadOutlineColor
边框颜色
intOutlineSize
边框宽度
boolShadowEnable
是否显示阴影
ColorQuadShadowColor
阴影颜色
Vector2ShadowOffset
阴影偏移值
boolRichText
超文本
intLineSpacing
行间距
boolAutoTranslator
是否开启自动翻译

函数

获取文本宽高尺寸

代码示例

lua
local workspace = game:GetService("WorkSpace")
local root = SandboxNode.new('UIRoot', workspace)
local label = SandboxNode.new('UITextLabel', root)
label.Title = "商店"
--设置背景框
label.LineColor = ColorQuad.new(0, 0, 0, 0)
--设置背景颜色
label.FillColor = ColorQuad.new(0, 0, 0, 0)
--设置字体颜色
label.TitleColor = ColorQuad.new(255, 0, 0, 255)
--设置位置
label.Position = Vector2.new(75,50)
--设置字体大小
label.FontSize = 18
--设置上下居中对齐
label.TextVAlignment = Enum.TextVAlignment.Center
--设置左右向左对齐
label.TextHAlignment = Enum.TextHAlignment.Left

--设置自动调整大小
label.IsAutoSize= true

--设置开启描边
label.OutlineEnable= true
--设置开启阴影
label.ShadowEnable= true
--获取字体大小
local size = label:GetTextSize()