[英]Strobe iPhone background - NSTimer?
I want to set up a simple strobe of the background. 我想设置一个简单的背景闪光灯。 I'd like to have a variable for frequency.
我想要一个频率变量。 Is NSTimer the best way to do this?
NSTimer是做到这一点的最佳方法吗? If so, how?
如果是这样,怎么办?
Thinking of maybe doing something like this: 考虑也许做这样的事情:
LOOP OF SOME KIND() {
self.window.backgroundColor = [UIColor redColor];
//DELAY - the amount is the frequency
self.window.backgroundColor = [UIColor blackColor];
}
FYI, I have a UISlider that's outputting values 0 to 255 for the frequency. 仅供参考,我有一个UISlider,它为频率输出0到255的值。 So, 0 is no strobe.
因此,0不是频闪。 255 is very fast strobe.
255是非常快的闪光灯。
Thanks! 谢谢!
Instead of NSTimer
you could use a CADisplayLink
for that. 可以使用
CADisplayLink
代替NSTimer
。
http://developer.apple.com/library/ios/#documentation/QuartzCore/Reference/CADisplayLink_ClassRef/Reference/Reference.html http://developer.apple.com/library/ios/#documentation/QuartzCore/Reference/CADisplayLink_ClassRef/Reference/Reference.html
just save the timestamp when you last changed the color and if enough time passed change it again in the displaylink function. 只需保存上次更改颜色时的时间戳,如果经过的时间足够,请在displaylink函数中再次更改它。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.