Reputation: 16598
I have UIView subclass - actually a puzzle piece - with 2 different CGLayer initialized at initWithFrame.
In drawRect I have to blend this two layer, and the uppermost should have variable alpha depending on game-logic.
What is the best (most performance optimized) way to do this? Is there any CGLayer, or CGContext function that sets some alpha before drawing?
Upvotes: 3
Views: 1786
Reputation: 299345
Set the -opacity
of the layer. Remember that the layer's -opaque
setting must be NO. The default is NO, but it's commonly set to YES for performance reasons.
If you're already doing -drawInContext:
, then you can experiment with CGContextSetAlpha()
. Generally, though, you don't use -drawRect:
and layers at the same time. You usually let either the view or the layers do the drawing.
Upvotes: 6