-
-
Save sturdysturge/a034c2b99f76dc906e975a51448fbef9 to your computer and use it in GitHub Desktop.
CameraView for camera feed
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import SwiftUI | |
import AVFoundation | |
struct CameraView: UIViewRepresentable { | |
let preview = PreviewView() | |
func makeUIView(context: Context) -> PreviewView { | |
AVCaptureDevice.requestAccess(for: .video) { granted in | |
if granted { | |
DispatchQueue.main.async { | |
preview.videoPreviewLayer.session = AVCaptureSession(device: .builtInWideAngleCamera) | |
} | |
} | |
} | |
return preview | |
} | |
func updateUIView(_ uiView: PreviewView, context: Context) {} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment