在如何在 Pebble.js 中向窗口添加图像?,我尝试将图像添加到白色背景。图像是 png,因此它是透明的,但即使设置了 clear 参数,背景也会显示为黑色。对此有什么帮助吗?
编辑这是代码:
// function that adds general elements to the window (top bar, icon, title, and text)
var addElementsToWindow = function(window, text) {
// Top rectangle
var rect = new UI.Rect({
position: new Vector2(0, 0),
size: new Vector2(144, 26),
backgroundColor:'black'
});
// icon
var icon = new UI.Image({
position: new Vector2(100,20),
size: new Vector2(25,26),
backgroundColor: 'clear',
borderColor: 'clear',
image: 'images/menu_icon.png'
});
// Title text
var title = new UI.Text({
position: new Vector2(0, 30),
size: new Vector2(144, 138),
text:'Title',
font:'gothic-24-bold',
color:'black',
textOverflow:'wrap',
textAlign:'center',
backgroundColor:'white'
});
// Loading text
var subtext = new UI.Text({
position: new Vector2(0, 60),
size: new Vector2(144, 108),
text:text,
font:'gothic-24',
color:'black',
textOverflow:'wrap',
textAlign:'center',
backgroundColor:'white'
});
// Display the home screen
window.add(rect);
window.add(title);
window.add(subtext);
window.add(icon);
};
// Create the home screen
var home = new UI.Window();
addElementsToWindow(home, 'Loading...');
home.show();