creating custom camera with square view on iOS

前端 未结 2 1459
情歌与酒
情歌与酒 2020-12-16 20:02

I am trying to create a custom camera experience on iOS and the following code snippet is as far as I got. Basically I want the usual camera view (i.e. with the following bu

2条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-16 20:13

    You have two options for doing what you want, either stick with and customize a UIImagePickerController, or create your own by using the AVFoundation.

    The UIImagePickerController does provide a fair bit of customization options, and this similar thread has some good information on that: link.

    If you still want to make your own, I suggest heading over to the Apple Documentation and checking out this demo project called AVCam: link. However, it's way more in-depth than you'll probably need so I can recommend this video tutorial as well: link.

    If going for the last option, I would like to mention that to make the "actual camera" fit the frame of your previewLayer, you can set the videoGravity on the AVCaptureVideoPreviewLayer to AVLayerVideoGravityResizeAspectFill.

提交回复
热议问题