0

在我的应用程序上,我正在尝试初始化并呈现UIImagePickerViewController自定义大小的实例。基本上,我想要一个大小为 200x200 的方形视图悬停在我的 viewController 上。我尝试了以下代码,它仍然以全屏模式显示相机覆盖。关于如何在叠加视图上实现自定义框架的任何建议?

UIImagePickerController *imagePickerController = [[UIImagePickerController alloc] init];
imagePickerController.modalPresentationStyle = UIModalPresentationCurrentContext;
imagePickerController.sourceType = UIImagePickerControllerSourceTypeCamera;
imagePickerController.delegate = self;                                          imagePickerController.showsCameraControls = NO;
imagePickerController.cameraOverlayView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 200, 200)];
[self presentViewController:imagePickerController animated:NO completion:nil];

任何帮助表示赞赏。

4

2 回答 2

0

你需要使用cameraOverlayView属性。将此属性设置为包含大小为 200x200 的透明正方形的自定义视图。

注意您提供的代码:
当您创建视图[[UIView alloc] initWithFrame:CGRectMake(0, 0, 200, 200)];时,默认情况下它使用清晰(透明)颜色。这就是为什么您在启动后看不到它的原因。
更改它的背景颜色,它将在相机层上变得可见:

UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 200, 200)];
view.backgroundColor = [UIColor redColor];
imagePickerController.cameraOverlayView = view;
于 2014-04-27T19:38:33.280 回答
0

您需要在 Apple 开发人员库中查看为 ios 及其 API 启用的人脸检测功能。CoreImageFramework 提供了在检测时您可以将鼠标悬停的 API。CIImageFilter、CIFilter方法使用

如需参考,请阅读 Apple 文档并检查以下示例

方凸轮

使用 UIImagePIckerController 难以覆盖和 Hover on move ,使用 AVFoundation 框架以获得更好的结果

于 2015-01-08T12:48:05.440 回答