From cc8957cfca957fbb5cdfec687bb09482453da5a5 Mon Sep 17 00:00:00 2001 From: zilongshanren Date: Thu, 24 Mar 2016 21:27:26 +0800 Subject: [PATCH] fix editbox text vertical alignment --- cocos2d/core/editbox/CCSGEditBox.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/cocos2d/core/editbox/CCSGEditBox.js b/cocos2d/core/editbox/CCSGEditBox.js index 94c1acbbdb..8e640f9374 100644 --- a/cocos2d/core/editbox/CCSGEditBox.js +++ b/cocos2d/core/editbox/CCSGEditBox.js @@ -250,9 +250,8 @@ EditBoxImpl.prototype = { }, _updateLabelPosition: function (editBoxSize) { - var textLabelSize = this._textLabel.getContentSize(); - this._placeholderLabel.setLineHeight(editBoxSize.height); this._textLabel.setContentSize(editBoxSize); + this._placeholderLabel.setLineHeight(editBoxSize.height); var placeholderLabelSize = this._placeholderLabel.getContentSize(); if (this._editBox._editBoxInputMode === InputMode.ANY){ @@ -264,7 +263,7 @@ EditBoxImpl.prototype = { } else { this._textLabel.enableWrapText(false); - this._textLabel.setPosition(cc.p(0, (editBoxSize.height + textLabelSize.height) / 2)); + this._textLabel.setPosition(cc.p(0, editBoxSize.height)); this._placeholderLabel.setPosition(cc.p(0, (editBoxSize.height + placeholderLabelSize.height) / 2)); this._placeholderLabel.setVerticalAlign(cc.VerticalTextAlignment.CENTER); this._textLabel.setVerticalAlign(cc.VerticalTextAlignment.CENTER);