为大量“LED”设置动画的策略- 线程?,UIView 动画? NS操作? (iPhone)
我必须制作一些包含 72 个 LED 灯的不同视图。我构建了一个 LED 类,这样我就可以循环 LED 并将它们设置为不同的颜色(绿色、红色、橙色、蓝色、无等)。 然后 LED 会加载适当的 .png。
这工作正常,我循环 LED 并设置它们。 现在我知道,有时他们不仅需要打开/关闭改变颜色,而且还需要稍微延迟打开。就像均衡器一样。
我有一个包含 72 个 LED 的 5-10 个视图,我希望以最小的内存/CPU 压力来实现上述目标。
for(LED *l in self.ledArray) {
[l display:Green];
}
我只是如上所示循环,LED 内部有一个执行正确逻辑的 switch case
。 如果这是实际的 LED 和微控制器,我会在循环中使用 sleep(100)
或类似的东西,但由于显而易见的原因,我真的很想避免类似的东西。
我认为执行 performOnThread withDelay
确实会很消耗,因此 UIView 动画
更改 alpha 和 NSOperation 对于一个小功能来说也会有很大的提升。
有没有一种既有效又聪明的方法来解决这个问题?
感谢您提供的任何灵感:)
I have to do some different views containing 72 LED lights. I built an LED Class so I can loop through the LED's and set them to different colors (Green, Red, Orange, Blue None etc.).
The LED then loads the appropriate .png.
This works fine, I loop over the LED's and set them.
Now I know that at some time they will need to not just turn on/off change color, but will have to turn on with a small delay. Like an equalizer.
I have a 5-10 views containing the 72 LED's and I would like to achieve the above with the minimum amount of memory/CPU strain.
for(LED *l in self.ledArray) {
[l display:Green];
}
I simply loop as shown above and inside the LED is a switch case
that does the correct logic.
If this were actual LED's and a microController I would use sleep(100)
or similar in the loop, but I would really like to avoid stuff like that for obvious reasons.
I was thinking that doing a performOnThread withDelay
would really be consuming, so would UIView animation
changing the alpha and NSOperation would also be a lot of lifting for a small feature.
Is there a both efficient and clever way to go around this?
Thanks for any inspiration given:)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我肯定会使用OpenGL!
I would definitely use OpenGL!