Drawing a UIImage on top of another within one UIImageView
-
20-08-2019 - |
Question
I have several different color block images that are reused in my game many times (its a simple rectangle for a puzzle game). I would like to apply a transparent overlay to each one of these images on the fly (a symbol for the puzzle block) which can be one of several different images. Is there a "best" way to get this done? Creating a subview seems like a bad idea here.
I ask this because it seems UIImageView and UIImage don't have the methods I need and I have yet to dive in to Core Graphics, but if I must I will. In fact, if anyone knows of a good tutorial please share.
Solution
A subview is actually not a bad idea, and it's the easiest to implement.
Another alternative is to use a UIView
and overwrite the drawRect
method, using Core Graphics to render your puzzle image and the overlay. Although this will be slightly slower than rendering a couple of UIImageViews
.