在你的界面中使用 2 个 UIImageView,在每个使用 UIImagePicker 之后,你可以使用这个代码:
- (IBAction)margeSave:(id)sender{
//here you get you two different image
UIImage *bottomImage = self.imageViewPick.image;
UIImage *image = self.myImage.image;
//here you have to crop each image with the code below
//using here a crop code and adjust for your Image
// create a new size for a merged image
CGSize newSize = CGSizeMake(640, 640);
UIGraphicsBeginImageContext( newSize );
[bottomImage drawInRect:CGRectMake(0,0,newSize.width,newSize.height)];
[myImage drawInRect:CGRectMake(0,0,newSize.width,newSize.height) blendMode:kCGBlendModeNormal alpha:1.0];
UIImage *newImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
UIImageWriteToSavedPhotosAlbum(newImage, nil, nil, nil);
//option if you are in other view when save
//[self.navigationController popViewControllerAnimated:YES];
}
您可以集成此代码来裁剪图像:
在 InterfaceBuilder 中使用图像的 2 部分来选择您想要的特定尺寸,例如在 iPhone 上使用 2 UIImageView W:150 H:300 total il a 300x300 并使用具有大小的裁剪图像。
CGRect clippedRect = CGRectMake(self.view.frame.origin.x+91, self.view.frame.origin.y, self.view.frame.size.width-91*2, self.view.frame.size.height-220);
CGImageRef imageRef = CGImageCreateWithImageInRect([image CGImage], clippedRect);
UIImage *imageCrop = [UIImage imageWithCGImage:imageRef];
CGImageRelease(imageRef);
希望对你有帮助