简体   繁体   English

如何在iOS中使用框架打开相机

[英]How to open camera with frame in iOS

How to bound iPhone camera inside a frame like below image. 如何在下图所示的框架内绑定iPhone相机。

在此处输入图片说明

Let the camera opens on full screen but the reading area will be only non blurred background in short i want to develop a screen shown in image. 让相机在全屏模式下打开,但阅读区域总之只有非模糊背景,我想开发一个如图所示的屏幕。

I have tried this code but it is not working... 我已经尝试过此代码,但无法正常工作...

    UIImagePickerController *picker = [[UIImagePickerController alloc] init];
    picker = [[UIImagePickerController alloc] init];
    picker.sourceType = UIImagePickerControllerSourceTypeCamera;
    picker.cameraCaptureMode = UIImagePickerControllerCameraCaptureModePhoto;
    picker.cameraDevice = UIImagePickerControllerCameraDeviceRear;
    picker.showsCameraControls = YES;
    picker.navigationBarHidden = YES;
    picker.view.frame = CGRectMake(0, 10, 200, 20); // NOT WORKING !!!
    picker.toolbarHidden = YES;
    picker.wantsFullScreenLayout = NO;
   // picker.delegate = delegate;

    CGAffineTransform transform = CGAffineTransformMakeTranslation(0.0f, 50.0f);
    transform = CGAffineTransformScale(transform, 1.2f, 1.2f);
    picker.cameraViewTransform = transform;

    [self presentViewController:picker animated:YES completion:nil];

how do i do this? 我该怎么做呢?

Thanks in advance! 提前致谢!

You have to create custom camera for that. 您必须为此创建自定义相机。 As I can see in the image you need to scan barcode. 正如我在图像中看到的,您需要扫描条形码。 For that you need to use 为此,您需要使用

  • AVCaptureSession AVCaptureSession
  • AVCaptureVideoPreviewLayer AVCaptureVideoPreviewLayer

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM