richText.string = 'aaa<color …>CCC; 1.9的 aaa会用 richText.node.color来渲染,到了2.x变成白色了
翻了翻代码
_applyTextAttribute (labelNode) {
let labelComponent = labelNode.getComponent(cc.Label);
if (!labelComponent) {
return;
}
let index = labelNode._styleIndex;
labelComponent.lineHeight = this.lineHeight;
labelComponent.horizontalAlign = HorizontalAlign.LEFT;
labelComponent.verticalAlign = VerticalAlign.CENTER;
let textStyle = null;
if (this._textArray[index]) {
textStyle = this._textArray[index].style;
}
if (textStyle && textStyle.color) {
labelNode.color = this._convertLiteralColorValue(textStyle.color);
}else {
labelNode.color = this._convertLiteralColorValue("white");
// label.setColor(this.node.color); // In version 1.9
}
这么搞就很郁闷了呀