views:

851

answers:

1

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.

A: 

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.

Marco Mustapic
Core Graphics slower than than having multiple views... really?
tmh
Core Graphics will draw on the surface of the view. If you need to update it every frame, it will be slow. If it's just in some cases, it's ok.But anyway, a couple of subviews per piece will do no harm to performance. As they say, "premature optimization is the root of all evil"
Marco Mustapic