开发者

How to find out the amount of time a button is being touched in iphone?

My requirement is to change a button color based on the time it is being pressed. for ex,button should be in re开发者_如何学God color if it is being touched for one sec, green for two secs, etc. How do i do it?

I could find out the amount of time after user takes his hand out, but I want it to be done when it is being pressed?. What is the efficient way to do it?.


U can start an NSTimer which fires every second , which is started when UIButton UIControlEventTouchDown control event is generated. And stop the timer when UIControlEventTouchUpInside or UIControlEventTouchUpOutside or UIControlEventTouchCancel event is generated. In between u can do the changes.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜