如何删除钛中文本字段的边框颜色?

时间:2015-10-06 10:40:03

标签: titanium titanium-mobile appcelerator appcelerator-mobile

我创建了一个自定义组件,该文本框左侧有一个笔图标(因为左键不支持HTML5 / WEB)。这是我的代码片段

    var bg = Ti.UI.createView({
        height : app.platform.isAndroid ? 35 : 31,
        top : 50,
        width:"94%",
        backgroundColor : "white",
        layout:"horizontal"
    });

    var leftBtnWeb = Ti.UI.createButton({
        backgroundImage : app.dir + "img/icons/pen.png",
        width : 25,
        top : 8,
        height : 16,
        touchEnabled : false,
    });
    bg.add(leftBtnWeb);

    input = Ti.UI.createTextField({
        // top : 5,
        width:'88%',
        // left : 2,
        // right : 20,
        height : 25,
        font : {
            fontSize : "16dp"
        },
        autocorrect : false,
        returnKeyType : Ti.UI.RETURNKEY_DONE,
        clearButtonMode : Ti.UI.INPUT_BUTTONMODE_ALWAYS,
        hintText:"test",
        backgroundColor:'transparent',
        zIndex : 10,
        borderColor : "transparent",
        backgroundSelectedColor : "transparent",
        backgroundFocusedColor : "transparent",
        backgroundImage : "transparent",
        focusedColor : "transparent",
        borderStyle : Ti.UI.INPUT_BORDERSTYLE_NONE

    }); 
    bg.add(input);`

当我专注于文本字段时,我得到了蓝色边框,任何人都可以让我知道如何在聚焦时删除该边框。

先谢谢, Swathi。

1 个答案:

答案 0 :(得分:2)

我的第一个想法是将自定义焦点事件监听器附加到文本字段并再次设置边框的颜色。

input.addEventListener('focus', function() {
    borderStyle : Ti.UI.INPUT_BORDERSTYLE_NONE
    this.hasFocus = true;
});

您可以尝试的另一件事是将backgroundColor设置为透明,如下所示:

backgroundColor : 'transparent'
相关问题