Skip to content

Instantly share code, notes, and snippets.

@vknabel
Created July 14, 2015 12:10
Show Gist options
  • Save vknabel/f81a9d89eb46a3f53ed4 to your computer and use it in GitHub Desktop.
Save vknabel/f81a9d89eb46a3f53ed4 to your computer and use it in GitHub Desktop.
import UIKit
import AVFoundation
class CameraPreviewView: UIView {
override class func layerClass() -> AnyClass {
return AVCaptureVideoPreviewLayer.self
}
var session: AVCaptureSession! {
get {
let layer = self.layer as? AVCaptureVideoPreviewLayer
return layer?.session
}
set {
if let layer = self.layer as? AVCaptureVideoPreviewLayer {
layer.session = newValue
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment