From 4a1eb9e0d9bb73f7bca0855b507ee91a78bcb277 Mon Sep 17 00:00:00 2001 From: zilongshanren Date: Mon, 10 Oct 2016 16:03:25 +0800 Subject: [PATCH] only reset node height in resize_height --- cocos2d/core/components/CCLabel.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/cocos2d/core/components/CCLabel.js b/cocos2d/core/components/CCLabel.js index 6b305fcdd7..868c3cad03 100644 --- a/cocos2d/core/components/CCLabel.js +++ b/cocos2d/core/components/CCLabel.js @@ -493,9 +493,17 @@ var Label = cc.Class({ _updateNodeSize: function () { var initialized = this._sgNode && this._sgNode.parent; if (initialized) { - if (this.overflow === Overflow.NONE || this.overflow === Overflow.RESIZE_HEIGHT) { + if (this.overflow === Overflow.NONE) { this.node.setContentSize(this._sgNode.getContentSize()); } + + if(this.overflow === Overflow.RESIZE_HEIGHT) { + //call this.node.getContentSize actually sync the node size with sgNode + //such that it won't trigger setDimensions method in jsb + var originalSize = this.node.getContentSize(); + var newSize = this._sgNode.getContentSize(); + this.node.setContentSize(cc.size(originalSize.width, newSize.height)); + } } } });