版本:3.7.1
平台:chrome
let str = 'test'; this._text = this.node.getChildByName('text').getComponent(Label); this._bar = this.node.getChildByName('bar'); this._text.node.on(Node.EventType.SIZE_CHANGED, () => { const width = this._text.node.getComponent(UITransform).width; const uiTransform = this._bar.getComponent(UITransform); uiTransform.setContentSize(new Size(width + 80, 110)); }, this); this.schedule(() => { str += '|test'; this._text.string = str; }, 1, 10);
_bar的宽度一直没变化。




,可以了。 但是 不明白为啥会这样,因为在回调的方法里面,确实是获取到了label的最新width。只是去改变bar的size。一直在找bar的问题。现在是给调用label的updateRenderData就好了。