开发者

How can I implement a strobe light on my iPhone 4

开发者 https://www.devze.com 2023-01-21 05:29 出处:网络
I would like to implement a strobe light on my iphone 4 I already have the code to turn on and off the LED.

I would like to implement a strobe light on my iphone 4 I already have the code to turn on and off the LED.

I figure I should use an NSTimer to repeat the method that turn the light on and off, also i figure i would use a UISlider to change the rate at wh开发者_如何学Cich the strobe flashes.

I just need to know what the best way to implement the strobe would be. I'd really appreciate any help I could get on this.


(No idea why anyone would vote this down -- perfectly reasonable question, if vague).

It sounds like your approach is pretty reasonable; using an NSTimer in that fashion will be about as passive as you can get and a UISlider is certainly a reasonable control.


Here's a solution in human words/pseudo:

Create a method that inits NSTimer with a parameter (float) setting the timer interval.

Users interaction with the slider should stop the timer, and init it with the sliders new value.

Simple. Just make sure that you set the max and min values of the slider to something reasonable in IB. At first set it high (like 1 second) as proof of concept.

0

精彩评论

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