You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Incisor TextBox文本与背景颜色独立设置问题求助

Incisor TextBox文本与背景颜色独立设置问题求助

嗨各位开发者,我最近在用Incisor的TextBox组件时遇到了一个颜色设置的问题——没法独立修改文本颜色和背景颜色,折腾了好一阵都没搞定,想请大家帮忙看看。

情况是这样的:我原本想实现红色文字+绿色背景的效果,写了下面这段代码:

class ProjectMain {
    init() {
        let textBox = new TextBox();
        textBox.string = "Hello World";
        textBox.backgroundColor = new Color(0, 1, 0, 1); // 绿色背景
        textBox.colorMultiply.red = 1;  // 尝试把文字改成红色
        textBox.colorMultiply.green = 0;
        textBox.colorMultiply.blue = 0;
    }
}

结果实际显示的是红色文字+黑色背景,完全不是我预期的样子。

但如果我去掉colorMultiply相关的设置,只保留背景色的代码,就能正常显示绿色背景+白色文字:

let textBox = new TextBox();
textBox.string = "Hello World";
textBox.backgroundColor = new Color(0, 1, 0, 1); // 绿色背景搭配白色文字

有没有大佬能帮我解释下,到底该怎么正确设置TextBox的文本颜色和背景色,让它们能独立生效呢?

备注:内容来源于stack exchange,提问作者John

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.04.15 10:24:30