fancy
fancy

Reputation: 2149

iOS: Create UIImage from the background thread?

Apples documentation says:

Because image objects are immutable, you cannot change their properties after creation. Most image properties are set automatically using metadata in the accompanying image file or image data. The immutable nature of image objects also means that they are safe to create and use from any thread.

Link

Also if you look at the answers of this "Thread safety of UIImage" question, it is concluded that it is safe to use them from any thread (at least since iOS 9).

Yet, there are comments that complain about issues, especially about creating UIImages on a background thread.

In my case I'm sure that this leads an issue where animations stop working. Does anybody have insights on this?

Upvotes: 6

Views: 2015

Answers (1)

Declan McKenna
Declan McKenna

Reputation: 4870

I can't see your code but I suspect this is a UIImage vs UIImageView issue if you're experiencing animation problems.

A UIImage manages image data off screen.
A UIImageView displays your image on to your user interface.

Handling image data off the main thread with UIImage is fine.
Displaying or animating an image with UIImageView is not.

Upvotes: 4

Related Questions