Created
July 14, 2015 13:33
-
-
Save vknabel/46bc835074e27164fece to your computer and use it in GitHub Desktop.
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 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