簡體   English   中英

頻閃iPhone背景-NSTimer?

[英]Strobe iPhone background - NSTimer?

我想設置一個簡單的背景閃光燈。 我想要一個頻率變量。 NSTimer是做到這一點的最佳方法嗎? 如果是這樣,怎么辦?

考慮也許做這樣的事情:

LOOP OF SOME KIND() {
self.window.backgroundColor = [UIColor redColor];
//DELAY - the amount is the frequency
self.window.backgroundColor = [UIColor blackColor];
}

僅供參考,我有一個UISlider,它為頻率輸出0到255的值。 因此,0不是頻閃。 255是非常快的閃光燈。

謝謝!

可以使用CADisplayLink代替NSTimer

http://developer.apple.com/library/ios/#documentation/QuartzCore/Reference/CADisplayLink_ClassRef/Reference/Reference.html

只需保存上次更改顏色時的時間戳,如果經過的時間足夠,請在displaylink函數中再次更改它。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM