我试图让用户将预先选择的图像拖放到他们从图书馆或照片库中选择的图像上,并将新编辑的图像作为一个整体保存。
下面的代码合并了两个图像,但没有将第二个图像保存在用户选择的同一位置。“userImage”是非静态的。再次感谢您的任何意见!
//Saves the image to the camera roll
- (IBAction)savePhoto:(id)sender {
UIImage *backgroundImage = [imageView image]; //This image is static
//This image will be moved around by a touchesMoved event
UIImage *userImage = [UIImage imageNamed:@"chopper_stash.png"];
UIGraphicsBeginImageContext(backgroundImage.size);
[backgroundImage drawInRect:CGRectMake(0, 0, backgroundImage.size.width, backgroundImage.size.height)];
//I realize that this sends the image to the top left, but how do I declare it's new location
[userImage drawInRect:CGRectMake(0,0, userImage.size.width, userImage.size.height)];
UIImage *result = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
//Save it to the camera roll
UIImageWriteToSavedPhotosAlbum(result, nil, nil, nil);
}