titanium钮在select时不会改变背景颜色
我有一个新手问题:我在Titanium for iPhone中创build的一个简单的button在单击时拒绝更改颜色。 原来我用这个button来实现这个function, 因为它不工作,我改变了一个视图,但都没有工作。 在这里它是如何build立的:
var quifButton = Ti.UI.createView({ // tried this with createButton, as well top: 44, left: 5, width: 310, height: 42, backgroundColor: '#333', backgroundSelectedColor: '#fff', backgroundFocusedColor: '#fff', touchEnabled: true, borderColor: BOR_DK, borderWidth: 2, borderRadius: 5 });
当我点击iPhone模拟器中的button/视图时,没有任何反应。 任何想法为什么这不起作用,我怎么能使它工作?
点击与焦点不同。 如果你想改变点击颜色,你必须添加eventlistenerbutton或视图。
quifButton.addEventListener('click', function(e){ quifButton.backgroundColor = '#fff'; });
* 编辑:
backgroundSelectedColor: '#fff', backgroundFocusedColor: '#fff',
这些在iOS中不受支持。
这是iOS中的一个限制,与Titanium无关。
试试这个,而不是你正在寻找的行为:
someBtn.addEventListener('touchstart', function() { someBtn.backgroundColor = 'green'; }); someBtn.addEventListener('touchend', function() { someBtn.backgroundColor ='blue'; });
你的代码对我来说工作得很好。 你可以试试,让我知道它是否有效?
var win1 = Ti.UI.createWindow({ title:'home', backgroundColor:'white' }); var button1 = Ti.UI.createButton({ top: 44, left: 5, width: 310, height: 42, backgroundColor: '#333', backgroundSelectedColor: '#fff', backgroundFocusedColor: '#fff', touchEnabled: true, borderWidth: 2, borderRadius: 5 }); win1.add(button1); win1.open();
你可以在tss.hope中使用backgroundSelectedColor:“#colorcode”吗?
使用backgroundSelectedColor:“颜色”,它将工作