编辑框CCEditBox 设置字体不起作用

编辑框CCEditBox 字体设置:

var eb = UIDef.createEditBox(this.label_input, this);
eb.setPlaceholderFont(this.label_input.fontName, 25);   //设置字体和大小,缺少设置字体 ,字号大小不起作用

//创建编辑框

UIDef.createEditBox = function(label,delegate) {
    var input = new cc.Scale9Sprite();
    var editbox = new cc.EditBox(cc.size(label.width, label.height), input);
    editbox.setCascadeOpacityEnabled(false);
    editbox.setPosition(label.getPosition());
    editbox.setAnchorPoint(label.getAnchorPoint());
    editbox.setFontColor(label.getTextColor());
    editbox.setFontSize(label.fontSize);
    editbox.setFontName(label.fontName);
    editbox.setMaxLength(12);
    editbox.setReturnType(cc.KEYBOARD_RETURNTYPE_SEND);
    editbox.setDelegate(delegate);
    editbox.setPlaceHolder(label.string);

    var inputType = label.getCallbackName();
    var mode = 0,flag = 1;
    if(inputType) {
        var modes = {'Number':2,'Email':1,'Phone':3,'Url':4,'Decmal':5,'Single':6};
        var flags = {'Password':0,'Caps':2,'CapsAll':4}
        var opts = inputType.split('_');
        mode = modes[opts[0]];
        flag = flags[opts[1]] || 1;
    }
    editbox.setInputMode(mode||0);
    editbox.setInputFlag(flag||1);
    label.parent.addChild(editbox);
    label.removeFromParent();
    return editbox;
};

参考链接: http://shahdza.blog.51cto.com/2410787/1544213/


你可能感兴趣的:(Cocos2d-x)