AVCaptureVideoPreviewLayer orientation – need landscape

Swift 5.5, Xcode 13.2 private func updatePreviewLayer(layer: AVCaptureConnection, orientation: AVCaptureVideoOrientation) { layer.videoOrientation = orientation self.previewLayer?.frame = view.bounds } override func viewDidLayoutSubviews() { super.viewDidLayoutSubviews() if let connection = self.previewLayer?.connection { let currentDevice = UIDevice.current let orientation: UIDeviceOrientation = currentDevice.orientation let previewLayerConnection: AVCaptureConnection = connection if previewLayerConnection.isVideoOrientationSupported { switch orientation { case .portrait: self.updatePreviewLayer(layer: previewLayerConnection, orientation: .portrait) … Read more