跳到主要内容

SetBackgroundColor

设置当前内容控件的背景颜色。

语法

expression.SetBackgroundColor(color);

expression - 表示 ApiInlineLvlSdt 类的变量。

参数

名称必需/可选数据类型默认值描述
color可选ApiColor背景颜色。

返回值

boolean

示例

设置文档中容器的背景颜色。

// How can I set background color using an inline content control in a document?

// Set background color for an inline content control in a document.

let doc = Api.GetDocument();
let paragraph = doc.GetElement(0);
let inlineLvlSdt = Api.CreateInlineLvlSdt();
let run = Api.CreateRun();
run.AddText("This is an inline text content control with a transparent blue background.");
inlineLvlSdt.AddElement(run, 0);
inlineLvlSdt.SetBackgroundColor(Api.RGBA(0, 0, 255, 40));
paragraph.AddInlineLvlSdt(inlineLvlSdt);