1

I have this method to add an image over another image and obtain a merge result

- (UIImage*) createImage{
    UIImage *imageToShare = nil;
    UIImageView* imageView = [[UIImageView alloc] initWithFrame:[self.view frame]];
    imageView.image = currentImage;
    UIImageView* subView   = [[UIImageView alloc] initWithImage:imageToUse.image];
    [imageView addSubview:subView];

    UIGraphicsBeginImageContext(imageView.frame.size);
    [imageView.layer renderInContext:UIGraphicsGetCurrentContext()];
    imageToShare = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();

    [subView release];
    [imageView release];
    return imageToShare;
}

it work fine because my imageToShare it's ok, but the problem is that "subView" is an image that I can rotate and pinch for zoom and move...then when I do this method subView return to its original position...what can I do to save it in its state position over imageView?

djItu
  • 39
  • 7
cyclingIsBetter
  • 17,447
  • 50
  • 156
  • 241
  • What do you try to do? It’s not really clear from your description. If you want to allow the user to further modify the merged image, I would suggest to draw to a non-visible context and then assign the result to the UIImageView image property. – Rafael Bugajewski Jan 18 '13 at 16:50
  • yes yes... and what's the way to assign the imageView at this non-visible context? – cyclingIsBetter Jan 18 '13 at 16:51

1 Answers1

0

If you want to merge two images, keep the merged result, and let the user manipulate it further, a good way is to draw to an off-screen context with a specific size, then create a CGImageRef, and then assign it to the image view. Take a look at this question and the answers to see how it’s done.

Community
  • 1
  • 1
Rafael Bugajewski
  • 1,702
  • 3
  • 22
  • 37