I have two UIImageView on the UIView. Each UIImageView have one UIImage. Now i want create an one UIImage from two UIImageView.
Please give the suggestion how can i do this.
If your have a view with three UIImageViews and create corresponding outlets
IBOutlet UIImageView *imageView1;
IBOutlet UIImageView *imageView2;
IBOutlet UIImageView *imageView3;
You can do something like the following to combine imageViews 1 and 2 into imageView 3
UIGraphicsBeginImageContext(imageView1.image.size);
CGRect rect = CGRectMake(0, 0, imageView1.image.size.width, imageView1.image.size.height);
[imageView1.image drawInRect:rect];
[imageView2.image drawInRect:rect blendMode:kCGBlendModeScreen alpha:0.5];
UIImage *resultingImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
[imageView3 setImage:resultingImage];
CGBlendMode allows you to choose from any of the following compositing operations for your images:
enum CGBlendMode {
kCGBlendModeNormal,
kCGBlendModeMultiply,
kCGBlendModeScreen,
kCGBlendModeOverlay,
kCGBlendModeDarken,
kCGBlendModeLighten,
kCGBlendModeColorDodge,
kCGBlendModeColorBurn,
kCGBlendModeSoftLight,
kCGBlendModeHardLight,
kCGBlendModeDifference,
kCGBlendModeExclusion,
kCGBlendModeHue,
kCGBlendModeSaturation,
kCGBlendModeColor,
kCGBlendModeLuminosity,
kCGBlendModeClear,
kCGBlendModeCopy,
kCGBlendModeSourceIn,
kCGBlendModeSourceOut,
kCGBlendModeSourceAtop,
kCGBlendModeDestinationOver,
kCGBlendModeDestinationIn,
kCGBlendModeDestinationOut,
kCGBlendModeDestinationAtop,
kCGBlendModeXOR,
kCGBlendModePlusDarker,
kCGBlendModePlusLighter
};
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With