     //切换摄像头
     @IBAction func chageCamera(_ sender: Any) {
         guard let session = session else { return }
+        //0.添加动画效果
+        let rotaionAnim = CATransition()
+        rotaionAnim.type = "oglFlip"
+        rotaionAnim.subtype = "fromLeft"
+        rotaionAnim.duration = 0.5
+        view.layer.add(rotaionAnim, forKey: nil)
         
         //1.取出之前镜头的方向
         guard let videoInput = videoInput else { return}

        guard let devices = AVCaptureDevice.devices() as?[AVCaptureDevice] else{return}
        guard let device = devices.filter({$0.position == oritation}).first else {return}
        guard let newInput = try? AVCaptureDeviceInput(device: device) else {return}
        //移除之前的input 添加新的input
        session.beginConfiguration()
        session.removeInput(videoInput)
        if session.canAddInput(newInput) {
            session.addInput(newInput)
            self.videoInput = newInput
        }
        session.commitConfiguration()
        
    }
    


    //创建捕捉会话
    fileprivate var session :AVCaptureSession? = AVCaptureSession()
//    fileprivate var videoconnection: AVCaptureConnection?
    fileprivate var videoOutput: AVCaptureOutput?
    fileprivate var previewLayer: CALayer?
    fileprivate var videoInput: AVCaptureDeviceInput?
    override func viewDidLoad() {
