钛按钮在选择时不会更改背景颜色
问题描述:
我有一个新手问题:我在Titanium中为iPhone创建的简单按钮拒绝单击时更改颜色.最初,我使用按钮来实现此功能.由于它不起作用,因此我更改为视图,但均不起作用.在这里它是如何设置的:
I have a newbie question: A simple button I've created in Titanium for iPhone refuses to change colors when clicked. Originally I used a button for this function; since it didn't work, I changed to a View, but neither works. Here it how it is set up:
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模拟器中单击按钮/视图"时,什么也没有发生.有什么想法为什么不起作用以及如何使它起作用?
When I click the Button / View in the iPhone simulator, nothing happens. Any ideas why this doesn't work and how I can make it work?
答
点击与焦点不同.如果要在单击时更改颜色,则必须在按钮或视图中添加事件监听器.
Click is not same than focus. If you want to change color on click, you have to add eventlistener to button or view.
quifButton.addEventListener('click', function(e){
quifButton.backgroundColor = '#fff';
});
*
backgroundSelectedColor: '#fff',
backgroundFocusedColor: '#fff',
iOS不支持这些.