How to merge two UIImages programmatically?
While developing an application I came to this issue. I was suppose to merge 2 images programmatically.
I googled a little bit and found a function, then I modified it as follows for my requirements
-(UIImage *) mergeTwoImages: (UIImage *)bottomImage : (UIImage *)upperImage : (CGRect)rect
UIImage *image = upperImage;
CGSize newSize = CGSizeMake(bottomImage.size.width, bottomImage.size.height);
UIGraphicsBeginImageContext( newSize );
// Use existing opacity as is
// Apply supplied opacity
[image drawInRect:rect blendMode:kCGBlendModeNormal alpha:1.0];
UIImage *newImage = UIGraphicsGetImageFromCurrentImageContext();
We just need to pass both the images to be merged and also the co ordinates of the upper image.
Happy Coding 🙂