且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何创建自定义摄像头视图,而不是UIImagePickerViewController?

更新时间:2023-11-14 17:59:58

简单的方法是继续使用 UIImagePickerViewController ,但设置 showsCameraControls 到NO,并使用 cameraOverlayView 提供您自己的用户界面。



但更灵活)的方法是使用 AVFoundation 类别(特别是 AVCaptureVideoPreviewLayer AVCaptureStillImageOutput )构建自己的相机。

I created a simple application using UIImagePickerViewController for capturing from the camera, but I'd like to customize the interface for grabbing from the camera, such as adding some buttons.

UIImagePickerViewController doesn't allow this directly, so how would you create a custom view that allows for displaying the live camera feed and capturing from it?

The easy way is to continue to use UIImagePickerViewController but set showsCameraControls to NO and provide your own user interface using cameraOverlayView.

The more difficult (but more flexible) way is to use the AVFoundation classes (particularly AVCaptureVideoPreviewLayer and AVCaptureStillImageOutput) to construct your own camera.