Contents

AVCaptureVideoPreviewLayer

A Core Animation layer that displays video from a camera device.

Declaration

class AVCaptureVideoPreviewLayer

Mentioned in

Overview

Use this layer to provide a preview of the content the camera captures. A convenient way to use this class in iOS is to set it as the backing layer for a view as shown below.

class PreviewView: UIView {
    // Use a capture video preview layer as the view's backing layer.
    override class var layerClass: AnyClass {
        AVCaptureVideoPreviewLayer.self
    }
    
    var previewLayer: AVCaptureVideoPreviewLayer {
        layer as! AVCaptureVideoPreviewLayer
    }
    
    // Connect the layer to a capture session.
    var session: AVCaptureSession? {
        get { previewLayer.session }
        set { previewLayer.session = newValue }
    }
}

Topics

Creating a preview layer

Layer configuration

Configuring deferred start

Session configuration

Converting between coordinate spaces

Deprecated

See Also

Capture preview