Created
June 4, 2015 17:51
-
-
Save kishaningithub/0609fe899985be383a48 to your computer and use it in GitHub Desktop.
Revisions
-
kishaningithub revised this gist
Jun 4, 2015 . No changes.There are no files selected for viewing
-
kishaningithub created this gist
Jun 4, 2015 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,31 @@ class ViewController: UIViewController { var session:AVCaptureSession! override func viewDidLoad() { super.viewDidLoad() // Do any additional setup after loading the view, typically from a nib. } override func viewWillAppear(animated: Bool) { session = AVCaptureSession() session.sessionPreset = AVCaptureSessionPresetPhoto var inputDevice = AVCaptureDevice.defaultDeviceWithMediaType(AVMediaTypeVideo) var deviceInput = AVCaptureDeviceInput.deviceInputWithDevice(inputDevice, error: nil) as! AVCaptureDeviceInput session.addInput(deviceInput) var previewLayer:AVCaptureVideoPreviewLayer = AVCaptureVideoPreviewLayer(session: session) previewLayer.videoGravity = AVLayerVideoGravityResizeAspectFill previewLayer.frame = self.view.frame self.view.layer.insertSublayer(previewLayer, atIndex: 0) session.startRunning() } override func didReceiveMemoryWarning() { super.didReceiveMemoryWarning() // Dispose of any resources that can be recreated. } }