iPhone自定义相机叠加(加图像处理):操作方法

时间:2011-11-10 00:15:03

标签: iphone objective-c cocoa-touch ios5 uiimagepickercontroller

  

可能重复:
  How do you create a custom camera view, instead of UIImagePickerViewController?

App Store现在提供的许多图像共享应用都使用自定义相机,而不是Apple提供的标准相机选择器。

有没有人知道创建自定义相机的任何教程或技巧?

2 个答案:

答案 0 :(得分:36)

是的,从代码创建UIImagePickerController,调整其属性,在其上添加叠加层,并与您的控制器一起控制您在该叠加层上的任何内容:自定义控件,叠加图像等...

这就是这样的:

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];

OverlayViewController是您必须编写的控制器,用于控制您添加到叠加层中的所有内容。

pickerReference是您可以保留向相机发送订单的属性。例如,您可以从放置在叠加层上的UIButton的IBAction中调用以下内容:

[self.pickerReference takePicture];

答案 1 :(得分:13)