2012-12-20 59 views
1

我正在开发钛项目。我需要一个像下面这样的自定义搜索栏。自定义钛中的搜索栏取消按钮

Design doc

但是,当我创建的搜索栏,它看起来像;

Output

我想改变取消按钮的图像。我搜索了很多用于定制钛的搜索栏,但找不到任何解决方案。

我以下列方式创建搜索栏:

var searchLocation = Ti.UI.createSearchBar({ 
    showCancel:true, 
    height:55, 
    top:45, 
    width:'102%', 
    backgroundImage:"../../Images/bg_search.png", 
    borderRadius:'5' 
}); 

然后我尝试不同的东西。

  1. 我创建了一个视图,一个没有取消按钮和自定义按钮的搜索栏。
  2. 将该搜索栏添加到该视图
  3. 将该按钮添加到该搜索栏的右侧。

    //holder view 
    var searchHolder = Ti.UI.createView({ 
        height : 55, 
        width : '100%', 
        top  : 45, 
        backgroundImage:"../../Images/[email protected]", 
        layout : 'horizontal' 
    }); 
    
    //search bar 
    var serLocation = Ti.UI.createSearchBar({ 
        height:55, 
        top:0, 
        width:'85%', 
        backgroundImage:"../../Images/[email protected]" 
    }); 
    
    //Calendar button 
    var calButton = Ti.UI.createButton({ 
        height : 45, 
        width : 45, 
        backgroundImage:"../../Images/nav_calendar.png" 
    }); 
    
    searchHolder.add(serLocation); 
    searchHolder.add(calButton); 
    

它的工作完美。

但我正在寻找任何替代解决方案。有没有内置的方法来做到这一点?

在此先感谢。

回答

0

这里面没有bult-in-methods。你的工作解决方案是最好的。

+0

感谢您的回答:) –

+0

@Dawson Toth我添加了一个搜索栏,其中出现了一个自动聚焦底线,我该如何删除它。请帮助我 – allDroid

+0

@allDroid我真的不确定你的意思。 ..你应该创建一个新的SO问题,用截图和代码重现你的问题,看看社区是否可以帮助你! –