Skip to content

Instantly share code, notes, and snippets.

@mattdeboard
Created July 14, 2015 20:20
Show Gist options
  • Save mattdeboard/aa94b2a584cfc3d2103b to your computer and use it in GitHub Desktop.
Save mattdeboard/aa94b2a584cfc3d2103b to your computer and use it in GitHub Desktop.
func videoOrientation() {
let previewConn = self.previewLayer?.connection
let orientation = UIApplication.sharedApplication().statusBarOrientation
switch orientation {
case UIInterfaceOrientation.LandscapeLeft:
previewConn!.videoOrientation = AVCaptureVideoOrientation.LandscapeLeft
case UIInterfaceOrientation.LandscapeRight:
previewConn!.videoOrientation = AVCaptureVideoOrientation.LandscapeRight
case UIInterfaceOrientation.Portrait:
previewConn!.videoOrientation = AVCaptureVideoOrientation.Portrait
case UIInterfaceOrientation.PortraitUpsideDown:
previewConn!.videoOrientation = AVCaptureVideoOrientation.PortraitUpsideDown
default:
previewConn!.videoOrientation = AVCaptureVideoOrientation.LandscapeRight
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment