blend two uiimages
UIImage* bottomImage = [UIImage imageNamed:@"bottom.png"]; UIImage* topImage = [UIImageNamed:@"top.png"];
UIImageView* imageView = [[UIImageView alloc] initWithImage:bottomImage];
UIImageView* subView = [[UIImageView alloc] initWithImage:topImage];
subView.alpha = 0.5; // Customize the opacity of the top image.
[imageView addSubview:subView];
UIGraphicsBeginImageContext(imageView.frame.size);
[imageView.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage* blendedImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
[subView release];
[imageView release];
[self doWhateverIWantWith: blendedImage];
iPhone : warning: no ‘-renderInContext:’ method found – solution
with one comment
There is a simple solution to this pesky warning:
- Add the following to your .h file :
#import <QuartzCore/QuartzCore.h>
- You may also need to add “CoreGraphics.framework” to your project, if its not already there.