I need to draw a series of PNGs into a CGContext
so I can blend them together:
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextSe
You don't need to be using UIImageViews.
Instead, bracket your drawing between calls to UIGraphicsBeginImageContext
and UIGraphicsEndImageContext
.
For example (code not tried):
UIImage* uiimage = [UIImage imageNamed:@"image-name.png"];
UIImage* uiimage2 = [UIImage imageNamed:@"other-image-name.png"];
CGSize size = uiimage.size;
UIGraphicsBeginImageContext(size);
[uiimage drawAtPoint:CGPointZero blendMode:kCGBlendModeOverlay alpha:1.0];
[uiimage2 drawAtPoint:CGPointZero blendMode:kCGBlendModeOverlay alpha:1.0];
UIImage* blendedImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
If you want to use CG calls, call:
CGContextRef context = UIGraphicsGetCurrentContext();
to get the context ref.