How to preload images in iOS

When you’re displaying a UIImage in your view controller it’s hardly noticeable how long it actually takes for the engine to “draw” the picture. Lenoard van Driel has tested this and confirms it takes 80ms – or in television terms, 2 frames. That’s something worth putting an audio delay in for.

Drawing several images in the same place takes a long time, and certainly takes the smoothness out of your UI. Once drawn however, iOS can display those images much quicker because they’re magically cached in memory – something we don’t have direct access to before you ask.

The solution is to “pre-draw” or “preload” those images while they’re not in vision. Leonard has written a method which does just that:

Call this on all your images you’d like to preload, and then access them as normal – resulting in much faster draw times.

Thanks, Lenoard!

About Jay Versluis

Jay is a medical miracle known as Super Survivor. He runs two YouTube channels, five websites and several podcast feeds. To see what else he's up to, and to support him on his mission to make the world a better place, check out his Patreon Campaign.

1 thought on “How to preload images in iOS

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.