开发者

Sequentially "flash" UIButtons

I have a series of UIButtons from 0 to N with a background image which is a color. I want to take a sequence of numbers from 0 to N, run through it and flash the corresponding button for each number sequentially. I have thought of changing the background to white and using sleep, but I haven't been able to get it to work. The buttons must flash sequentially with equal time spacing between the flashes. Pseudocode is:

for(i in sequence){
    [[buttons objectAtIndex:i] flash];
    //The flash must complete before the next button flashes.
}

Is there anyway to simulate the same animation as a button press, because that would be perfect? Basically I'm doing these flashes to show the user the sequence in which to press the buttons, is there a more elegante way to do this? Should I use some custom view instead of UIButton (I need it to be开发者_如何转开发 clickable, but I could program that instead of using a button)?


NSTimer is your friend. Check up on the documentation for it. You could have it fire at a set interval and just increment the count each time it fires.

For animation look at the animation methods provided for in UIView's documentation. Should have everything you need.

DO NOT USE sleep under any circumstances. This will make everything completely non responsive while its sleeping. There are all sorts of other more useful methods that allow for delays.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜