钛按钮在选择时不会更改背景颜色 [英] Titanium button not changing background color when selected

查看:63
本文介绍了钛按钮在选择时不会更改背景颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个新手问题:我在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不支持这些.

这篇关于钛按钮在选择时不会更改背景颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆