titaniumtitanium-alloytitanium-android

how to change hintText color in textField Titanium?


this is my code,and I want to change the hintText Color, how to do?

    "#email":{
    width: '70%',
    left:'13%',
    font:{
        fontSize:'20sp'
    },
    color: '#fff',
    hintText:'请输入手机号',
    borderColor:'transparent',
    bottom:'2%',
    //backgroundColor:'#d9d9d9',
    backgroundColor:'transparent',
    borderStyle:Ti.UI.INPUT_BORDERSTYLE_ROUNDED
}

Solution

  • actually you can't i tried before
    here what i did to change the hint color and font
    you need to create a view, textfeild and label with adding change listener on textfeild to show or hide the hint

     var mh_view = Ti.UI.createView({
        backgroundColor : "white",
        height : "40dp",
        top : "224dp",
        left : "10dp",
        right : "10dp",
        width : Ti.UI.FILL
    });
    var mail_hint = Ti.UI.createLabel({
        color : "#88817F",
        font : {
            fontFamily : customfont2,
            fontSize : "15dp"
        },
        left : "47dp",
        //top:"14dp",
        text : "E-mail"
    });
    mh_view.add(mail_hint);
    var mail = Ti.UI.createTextField({
        backgroundImage : "/images/trans.png",
        width : Ti.UI.FILL,
        height : "40dp",
        top : "224dp",
        left : "10dp",
        right : "10dp",
        bubbleParent:false,
        paddingLeft : "47dp"
        // hintText:"E-mail"
    });
    
    var visible = true;
    mail.addEventListener("change", function() {
        if (visible) {
            mail_hint.hide();
        } else {
            if ((mail.value).length == 0)
                mail_hint.show();
        }
        visible = !visible;
    
    });
    

    hope it help :)