Setting a background image/view to live camera view?

前端 未结 3 808
失恋的感觉
失恋的感觉 2020-12-17 03:01

Is it possible to set a background for a particular view controller to show a live camera view? If so, could one lead me in the right direction to make this possible?

3条回答
  •  南方客
    南方客 (楼主)
    2020-12-17 03:47

    I think your best bet is to grab and understand this apple sample code, called AVCam. You'll see in the code how to create an AVCaptureVideoPreviewLayer. You'll insert this as a sublayer of a UIView that you'll use as your "background".

    Once you've got that working, that UIView will be just like any other part of your view hierarchy. You can treat it like a background UIImageView (albeit, one that consumes a lot more batter power).

提交回复
热议问题