func attachCameraPreview()

in BasicBroadcast/Utils.swift [38:49]


func attachCameraPreview(container: UIView, preview: UIView) {
    // Clear current view, and then attach the new view.
    container.subviews.forEach { $0.removeFromSuperview() }
    preview.translatesAutoresizingMaskIntoConstraints = false
    container.addSubview(preview)
    NSLayoutConstraint.activate([
        preview.topAnchor.constraint(equalTo: container.topAnchor, constant: 0),
        preview.bottomAnchor.constraint(equalTo: container.bottomAnchor, constant: 0),
        preview.leadingAnchor.constraint(equalTo: container.leadingAnchor, constant: 0),
        preview.trailingAnchor.constraint(equalTo: container.trailingAnchor, constant: 0),
    ])
}