Users need to be able to take photo of their ID. I need to add a blue frame to camera view as a guide. Guide should have same aspect ratio on all device sizes and fit a label with instructions. Can I accomplish this using UIImagePicker?
Here is some incomplete code. Thanks for any help.
UIImageView *overlayImage = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@""]];
CGRect overlayRect = CGRectMake(0, 0, self.view.frame.size.height - 16, self.view.frame.size.width - 16);
[overlayImage setFrame:overlayRect];
[self.imagePicker setCameraOverlayView:overlayImage];
Use
AVCaptureDevice
,AVCaptureSession
,AVCaptureVideoPreviewLayer
andAVCapturePhotoOutput
.Set
AVCaptureDeviceInput
as input of capture session, and photo output as output of capture session. InitializeAVCaptureVideoPreviewLayer
withAVCaptureSession
and add to yourview.layer
thoughtaddSublayer
. You can useUIViewController
from storyboard or programmatically instantiated controller, add picture of overlay or corneredview.layer.borderWidth
orUIBezierPath
. Set up controller asAVCapturePhotoCaptureDelegate
, add delegate methods. UsecapturePhoto(with:delegate:)
method. Enjoy.