Search code examples
iphoneiosxcodeuiimageviewuiimage

How to combine/ merge 2 images into 1


I would like to know what to do to save 2 images into 1 image.

One of the photos can be moved, rotated and zoomed in/out...

I'm doing this, but it basically captures all the stuff on the screen including my buttons...

UIGraphicsBeginImageContext(self.view.bounds.size);
[self.view.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *savedImg = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();

Solution

    1. Create a subview for adding images.
    2. Add all your images in that view instead of the main view.
    3. Let the buttons and other stuff stay on the main view.
    4. Render only the view with images in the bitmap context instead of the main view like you are doing right now.