我希望它看起来像这样 /image/QMXLF.jpg但看起来像这样/image/mOmMP.jpg
这是我的代码,我尝试创建一个标签并将其添加到行中,如下所示,还尝试创建一个 View (createView)并向其添加行和标签,但这只是创建一个白屏。
var Helpers = {};
// row maker
Helpers.createNavItem = function(options) {
var footHeight=120;
if (options.title == ''){
footHeight = 40;
}
var row = Ti.UI.createTableViewRow({
height:footHeight,
title: options.title,
backgroundImage: options.backgroundImage,
font:{
fontFamily: "Helvetica",
fontWeight: "bold",
fontSize: 18},
color: '#1d1d1d',
backgroundColor:'#b6e2e2',
zIndex: 1
});
var label = Ti.UI.createLabel({
bottom: 0,
height: 20,
width: 'fill',
backgroundColor: '#b6e2e2',
opacity: 50,
zIndex: 2
});
row.addEventListener('click', function (e) {
tab1.open(options.page);
});
return row;
return row.add(label);
};
请帮忙!!
最佳答案
要实现此目的,请尝试使用以下代码:
var win = Ti.UI.createWindow({
width: Ti.UI.FILL,
height: Ti.UI.FILL,
backgroundColor: "white",
layout: "vertical"
});
createMenuItem = function(title){
var menuView = Ti.UI.createView({
width: Ti.UI.FILL,
height: 120,
backgroundColor:'pink',
});
var titleView = Ti.UI.createView({
width: Ti.UI.FILL,
height: 40,
bottom: 0,
opacity: 50,
backgroundColor: "#b6e2e2",
layout: "horizontal"
});
var label = Ti.UI.createLabel({
top: 6,
left: 15,
text: title,
font:{
fontFamily: "Helvetica",
fontWeight: "bold",
fontSize: 18
}
});
var border = Ti.UI.createView({
width: Ti.UI.FILL,
height: 4,
bottom: 0,
backgroundColor: "white"
});
titleView.add(label);
menuView.add(titleView);
menuView.add(border);
win.add(menuView);
win.open();
//add event listeners below
};
var array = ["News", "1 Million Cups", "More Events"];
for(var i in array)
createMenuItem(array[i]);
用您的图像替换粉红色背景。
关于javascript - Titanium JavaScript - 将彩色对象放置在现有标签上,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26962503/