2012-04-02 53 views
1

中給出的那樣工作我想在文本按鈕上顯示圖標。我正在使用下面的代碼。Titanium.UI.Button屬性圖像不能像文檔

var refreshButton = Titanium.UI.createButton({ 
     image :'refresh.jpg', 
     top : 0, 
     height : 100, 
     left : width, 
     width : width, 
     title : 'Refresh' 
    }) 

from appcelerator api doc。

形象:圖像按鈕上顯示的標題

但像和backgroundImage

enter image description here

工作我缺少的東西左邊?

+0

我也面臨着同樣的問題。我在Titanium.UI.Button上爲'image'找到了兩個不同的文檔。 [鏈接1](http://developer.appcelerator.com/apidoc/mobile/1.0/Titanium.UI.Button)和[鏈接2](http://developer.appcelerator.com/apidoc/mobile/latest/Titanium .UI.Button對象) – Bongs 2012-05-16 11:26:22

回答

0

我得到了同樣的問題。

但是當圖像小於按鈕時不會發生。

我用我的按鈕的1/4的大小的圖像,它解決了我的問題。

0

嘗試將圖像添加爲按鈕的形象圖:

var button = Ti.UI.createButton({backgroundColor:'black',title:'General Info',textAlign:'left',width:210, height:30,top:20,left:20, color:'white', font:{fontFamily:'AppleGothic',fontWeight:'bold',fontSize:20}}); 

    var icon = Ti.UI.createImageView({ 
     image : "../images/icon.png", 
     height : 20, 
     width :20, 
     left : 5 
    }); 

button.add(icon)