钛JavaScript-将彩色对象放置在现有标签上
我希望它看起来像这样,但它看起来像这样 这是我的代码,我试着创建一个标签并将其添加到行中,如下图所示,还试着创建一个视图(createView)并将行和标签添加到该视图中,但这只会创建一个白色屏幕钛JavaScript-将彩色对象放置在现有标签上,javascript,view,label,row,tableview,Javascript,View,Label,Row,Tableview,我希望它看起来像这样,但它看起来像这样 这是我的代码,我试着创建一个标签并将其添加到行中,如下图所示,还试着创建一个视图(createView)并将行和标签添加到该视图中,但这只会创建一个白色屏幕 var Helpers = {}; // row maker Helpers.createNavItem = function(options) { var footHeight=120; if (options.title == ''){ footHeight = 40; } var ro
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]);
用图像替换粉红色背景