javascript - Titanium JavaScript - 将彩色对象放置在现有标签上

标签 javascript view label row tableview

我希望它看起来像这样 /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/

相关文章:

kubernetes - 在Grafana上使用Prometheus获取Pod的部署时间或上次重启时间

javascript - 运行函数后更改 Google map 标记 HTML

javascript - Jquery根据上面的元素动态平滑地调整底部元素的大小

android - 在一个按钮中携带短信而不在Android中显示它

sql-server - 使用奇怪的查询优化器行为连接 SQL Server 中的 View

Android 通过 touchEvent 从类 View 完成 Activity

javascript - json stringify 不能在 asp.net mvc 页面上工作

javascript - 在原始图像上应用 camanJS 滤镜

android - 如何在 Android 中创建一个带有 fontawesome 字符串作为 "icon"和普通文本作为标签的按钮?

c# - 使用点击事件访问同一个类中的另一个变量