请问cc.EditBox怎样设置其文本居中显示

失去焦点,又左对齐了,怎么解决:2:

一样,关注一下

bool CCEditBoxImplIOS::initWithSize(const CCSize& size)
{
do
{
CCEGLViewProtocol* eglView = CCEGLView::sharedOpenGLView();

    CGRect rect = CGRectMake(0, 0, size.width * eglView->getScaleX(),size.height * eglView->getScaleY());

    float factor =  contentScaleFactor];
    rect.size.width /= factor;
    rect.size.height /= factor;
    
    m_systemControl =  initWithFrame:rect editBox:this];
    if (!m_systemControl) break;
    m_systemControl.textField.textAlignment =  NSTextAlignmentCenter;

    initInactiveLabels(size);
    setContentSize(size);
    
    return true;
}while (0);

return false;

}

void CCEditBoxImplIOS::initInactiveLabels(const CCSize& size)
{
const char* pDefaultFontName = UTF8String];

m_pLabel = CCLabelTTF::create("", "", 0.0f,size,kCCTextAlignmentCenter,kCCVerticalTextAlignmentBottom);
m_pLabel->setAnchorPoint(ccp(0, 0.5f));
m_pLabel->setColor(ccWHITE);
m_pLabel->setVisible(false);

m_pEditBox->addChild(m_pLabel, kLabelZOrder);


m_pLabelPlaceHolder = CCLabelTTF::create("", "", 0.0f,size,kCCTextAlignmentCenter,kCCVerticalTextAlignmentBottom);
// align the text vertically center
m_pLabelPlaceHolder->setAnchorPoint(ccp(0, 0.5f));
m_pLabelPlaceHolder->setColor(ccGRAY);
m_pEditBox->addChild(m_pLabelPlaceHolder, kLabelZOrder);

setFont(pDefaultFontName, size.height*2/3);
setPlaceholderFont(pDefaultFontName, size.height*2/3);

}

v3.10 版本的 Editbox问题更严重,文字倒是有居中,但是点出输入框弹出键盘后,整个文字往上偏移,关闭输入又恢复居中。PlaceHolder的字号和正文的字号明明设置相同,但PlaceHolder明显被放大了。

请问改底层的具体步骤是什么 小白不知道怎么改。