views:

39

answers:

1

For a little practise fun project I did this:

I added a grid of UIView instances to an view controllers view which work pretty much like an number segment LCD (but those LCD screens that have squares and can show pretty much anything, not just numbers...with low resolution though).

There are 8 * 8 views on the screen (so 64 views, in total). A controller object is able to set the color of every view, to show a certain number. I've programmed already the "matrix" for the number 8.

I'd like to add some kind of noise effect like an broken TV with no reception. When there is no number to show, then all those 64 views must flash wildly with all kinds of rainbow colors, as fast as possible.

My for loop that goes over all those views and sets the backgroundColor can only do like 5 to 10 times per second. The screen doesn't update fast enough and it doesn't look really like TV noise.

Would it be a lot faster when I would implement this matrix in OpenGL ES and then show this OpenGL ES view instead? How hard is it to make a matrix of addressable squares in OpenGL ES?

+1  A: 

Updating 64 UIViews at a high frequency is going to be difficult. I'd suggest using one UIView and creating 64 CALayers inside that view.

TomH
Is CALayer faster than UIView about updating?
Toro
Swapping out a CALayer is faster than drawing into a view.
hotpaw2
Yes. In fact UIview is built on CALayer. What you will ultimately end up doing is creating new CALayers and adding them as sublayers of the UIView's layer.
TomH
Isn't UIView simply an wrapper around CALayer? Some few method calls might be skipped, but I can't imagine this is a big improvement?
openfrog