我正在尝试为使用imagePicker拍摄的图像添加叠加效果,例如在拍摄过程中显示的帧。我试图使用以下代码:
self.picker = [[UIImagePickerController alloc] init];
self.picker.sourceType = UIImagePickerControllerSourceTypeCamera;
self.picker.cameraCaptureMode = UIImagePickerControllerCameraCaptureModePhoto;
self.picker.cameraDevice = UIImagePickerControllerCameraDeviceRear;
self.picker.showsCameraControls = NO;
self.picker.navigationBarHidden = YES;
self.picker.toolbarHidden = YES;
self.picker.wantsFullScreenLayout = YES;
// Insert the overlay
self.overlay = [[OverlayViewController alloc] initWithNibName:@"Overlay" bundle:nil];
self.overlay.pickerReference = self.picker;
self.picker.cameraOverlayView = self.overlay.view;
self.picker.delegate = self.overlay;
[self presentModalViewController:self.picker animated:NO];
但这有助于更改图像选取器皮肤。如何使用快照添加和处理叠加层?
答案 0 :(得分:0)
如果您需要将拍摄的照片与包含图像的另一个UIImageView合并,这是一个有用的片段:
<强> yourFile.h:强>
UIImage *combinedImage;
<强> yourFile.m:强>
-(void)savePicture { // call this method from an IBAction button
// Crop a Combined Image from the taken picture
CGRect rect = [_imagePreview bounds];
UIGraphicsBeginImageContextWithOptions(rect.size,YES,0.0f);
// Render both images, the captured one from the camera and the UIImageView that is over that picture
[__myCapturedImage.layer renderInContext:UIGraphicsGetCurrentContext()];
[_overlayImageView.layer renderInContext:UIGraphicsGetCurrentContext()];
combinedImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
_myCapturedImage.image = combinedImage;
// Automatically Save the Image into Photo Album (if you want to do so)
UIImageWriteToSavedPhotosAlbum(combinedImage, nil, nil, nil);
}
希望这有帮助!
PS:我们制作了一个很好的模板,实际上处理覆盖图像(图像周围的帧):http://codecanyon.net/item/picshape-frame-image-editor-full-app-template/7852895?ref=fvimagination
干杯!