Performance UIImageView vs UIView with QuartzCore

234 views Asked by At

So I just discovered QuartzCore, and I am now considering to replace a UIImageView containing a bitmap with a UIView subclass doing things like

CGContextFillEllipseInRect(contextRef, rect);

They would look exactly the same: the bitmap is just a little filled circle.

The very view I'm replacing is playing an important role in my app: it's being dragged around a lot.

Question: performance wise: should I bother? I can imagine that the vector circle is being recalculated all of the time, while the bitmap is just buffered. Or that the vector is easier to digest than a bitmap.

Can anyone advise?

thanks ahead

1

There are 1 answers

1
Stephen Johnson On BEST ANSWER

All UIView's on iOS are layer backed. So drawRect will only be called once and you will draw to the CALayer backing the view. You can have it draw again by calling setNeedsDisplay. When you are dragging the view around and drawing it, the view will render from the layer backing. Using a UIImageView is also layer backed and so the end result should be two layer backed views. The one place where you may see a difference is in low memory situations when the view is not visible (though I am not sure).