Reputation: 3149
When a view is hidden or alpha=0 does it still cost CPU power or is it ignored?
if I go:
[view setAlpha:0];
then
[view setFrame:newFrameRect];
What is the performance implication of that?
Upvotes: 4
Views: 839
Reputation: 4793
"Something with an alpha of zero, still is drawn, however a view that is hidden is not redrawn to the screen. Since this only happens when the view changes anyways, the difference should be insignificant..."
Therefore, setHidden is useful, while changing the alpha is not as beneficial.
In general, memory-wise, there is little benefit. You need to remove from view in order to maximize performance, but the change is so small, it probably won't matter.
Upvotes: 3
Reputation: 6834
I doubt there would be a significant difference. Though im just speculating here. The reason I say this is because ios devices have a gpu, and in this day in age these are very sophisticated. Sophisticated in the sense that if alpha is 0, there is nothing to render, so it's just a simple check with respect to processing cycles. And I am assuming it is smart enough to do this check because graphics chips are smart enough to not render something that is outside of the viewport (or hidden behind foreground pixels).
Maybe running the performance tool on a test app would reveal something more concrete.
Upvotes: 1