iOS Best way to draw multiple small images on a large UIView

607 Views Asked by At

I have a very, very large UIView, which uses a CATiledLayer.

I need to render a lot of small images onto it.

These small images are stored in one large image (1024x1024). They may have transparency.

At the moment, I use CGImageCreateWithImageInRect on the large image to create CGImageRefs for each small image that I need.

Later, within drawRect, I call CGContextDrawImage(context, rect, smallImage); to display each of these small images, as required.

According to Instruments' Time Profiler, however, there's a very large bottleneck at CGContextDrawImage (274ms), and I wish to reduce that as best I can (short of using OpenGL).

My question is: how? Is there an alternative to CGContextDrawImage which does not require scaling? Is using CGImageCreateWithImageInRect the right way to go about it?

0

There are 0 best solutions below