我需要在Titanium studio(版本3.1.1)的按钮中添加背景图像。我尝试了几乎所有我能想到的东西,但按钮图像仍未出现。图像文件路径是正确的。我清理了项目,重新启动钛仍然无法正常工作。当我试图添加窗口背景图像时,我遇到了同样的问题,它没有出现,突然它甚至没有更改代码行。我该如何解决这个问题?
var pauseResumeButton = Titanium.UI.createButton({
title:"play",
top:'70%',
width:80,
height:80,
backgroundColor:'green',
backgroundImage:"/graphics/play.png",
});
答案 0 :(得分:0)
尝试以下代码
var pauseResumeButton = Titanium.UI.createButton({
title:"play",
top:'70%',
width:80,
height:80,
backgroundColor:'green',
backgroundImage:"graphics/play.png",
});
另请参阅this回答
答案 1 :(得分:0)
尝试将按钮的背景更改为transparent
,如下所示:
var pauseResumeButton = Titanium.UI.createButton({
title:"play",
top:'70%',
width:80,
height:80,
backgroundColor:'transparent',
backgroundImage:"graphics/play.png",
})
win.add( pauseResumeButton )