跳到主要内容

GetTextColor

获取控件文本颜色。

语法

expression.GetTextColor();

expression - 表示 ApiBaseWidget 类的变量。

参数

此方法没有任何参数。

返回值

ApiColor

示例

此示例获取字段控件并显示其文本颜色。

let doc = Api.GetDocument();
let page = doc.GetPage(0);
let textField = Api.CreateTextField([10, 10, 160, 30]);
page.AddObject(textField);

textField.AddWidget(0, [10, 40, 160, 60]);
let widgets = textField.GetAllWidgets();
let rgbColor = Api.RGB(255, 100, 0);
widgets.forEach(function(widget) {
widget.SetTextColor(rgbColor);
});
let bgColor = widgets[0].GetTextColor();
textField.SetValue('Widgets text color is: ' + bgColor.R + ',' + bgColor.G + ',' + bgColor.B);