Skip to content

Instantly share code, notes, and snippets.

@Danesz
Created May 14, 2020 21:45
Show Gist options
  • Save Danesz/2a0d966650e155d52fbba396f610f531 to your computer and use it in GitHub Desktop.
Save Danesz/2a0d966650e155d52fbba396f610f531 to your computer and use it in GitHub Desktop.
CameraViewController.swift - photoOutput
func photoOutput(_ output: AVCapturePhotoOutput, didFinishProcessingPhoto photo: AVCapturePhoto, error: Error?) {
//process single image
guard let imageData = photo.fileDataRepresentation()
else { return }
let captureImageView = UIImageView(frame: CGRect(x: 50, y: 50, width: 100, height: 100))
let image = UIImage(data: imageData)
captureImageView.image = image
//show the captured image
let centerView = UIView(frame: CGRect(x: UIScreen.main.bounds.size.width / 2 - 100,
y: UIScreen.main.bounds.size.height / 2 - 100,
width: 200,
height: 200))
centerView.backgroundColor = UIColor.red
centerView.addSubview(captureImageView)
self.view.addSubview(centerView)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment