0

I'm working on an Acne app in which I have to choose image from UIImagePicker and after adding subViews to it I want to save it in camera roll.

Problem: If I add UIImageView as a subView to the superView, the pickerImage does not save with subView.

And if I add that UIImage as subView to the Picker Image, I am unable to move the added UIImage Views.

I am using the following code for saving images:

-(IBAction)savePhoto
{


NSParameterAssert(imgToDisplayFromPicker.image);
UIImageWriteToSavedPhotosAlbum(imgToDisplayFromPicker.image, nil, nil, nil);


}
altocumulus
  • 21,179
  • 13
  • 61
  • 84
Iphone Developer
  • 163
  • 2
  • 14

1 Answers1

2

Finally Found the Solution :

CGRect contextRect = CGRectMake(6, 6, 302, 230);

UIGraphicsBeginImageContext(contextRect.size);

[self.view.layer renderInContext : UIGraphicsGetCurrentContext()];

UIImage *viewImage = UIGraphicsGetImageFromCurrentImageContext();

UIGraphicsEndImageContext();

CGImageRef imageRef = CGImageCreateWithImageInRect([viewImage CGImage], contextRect);

UIImage * newImage = [UIImage imageWithCGImage:imageRef scale:1.0 orientation:viewImage.imageOrientation];

UIImageWriteToSavedPhotosAlbum(newImage, nil, nil, nil);
Iphone Developer
  • 163
  • 2
  • 14