开发者

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

开发者 https://www.devze.com 2023-03-19 02:27 出处:网络
My requirement is to change a button colorbased 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

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

精彩评论

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