Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save vknabel/46bc835074e27164fece to your computer and use it in GitHub Desktop.
Save vknabel/46bc835074e27164fece to your computer and use it in GitHub Desktop.
import UIKit
import AVFoundation
public extension AVCaptureVideoOrientation {
public init(interfaceOrientation: UIInterfaceOrientation) {
switch interfaceOrientation {
case .Unknown:
self = .LandscapeLeft
case .Portrait:
self = .Portrait
case .PortraitUpsideDown:
self = .PortraitUpsideDown
case .LandscapeLeft:
self = .LandscapeLeft
case .LandscapeRight:
self = .LandscapeRight
}
}
public var interfaceOrientation: UIInterfaceOrientation {
switch self {
case .Portrait:
return .Portrait
case .PortraitUpsideDown:
return .PortraitUpsideDown
case .LandscapeLeft:
return .LandscapeLeft
case .LandscapeRight:
return .LandscapeRight
}
}
}
public extension UIInterfaceOrientation {
public init(captureVideoOrientation: AVCaptureVideoOrientation) {
self = captureVideoOrientation.interfaceOrientation
}
public var captureVideoOrientation: AVCaptureVideoOrientation {
return AVCaptureVideoOrientation(interfaceOrientation: self)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment