| | |
| | | self.navigationController?.popViewController() |
| | | } |
| | | } |
| | | |
| | | |
| | | // if(!checkCameraAuth()){ |
| | | // |
| | | // let authStatus = AVCaptureDevice.authorizationStatus(for: AVMediaType.video) |
| | | // if authStatus == AVAuthorizationStatus.notDetermined { |
| | | // AVCaptureDevice.requestAccess(for: AVMediaType.video) {[weak self] (granted) in |
| | | // if granted{ |
| | | // self?.setupCaptureSession() |
| | | // self?.addSubviews() |
| | | // self?.scanTimer = Timer.scheduledTimer(timeInterval: 3.0, target: self, selector: #selector(startAnimation), userInfo: nil, repeats: true) |
| | | // } |
| | | // } |
| | | // } else if authStatus == AVAuthorizationStatus.restricted || authStatus == AVAuthorizationStatus.denied { |
| | | // let alertController = UIAlertController(title: nil,message: "请在iphone的“设置-隐私-相机”选项中,允许应用访问你的相机", preferredStyle: .alert) |
| | | // let cancelAction = UIAlertAction(title: "取消", style: .cancel, handler: { action in |
| | | // self.navigationController?.popViewController(animated: true) |
| | | // }) |
| | | // |
| | | // let okAction = UIAlertAction(title: "前往", style: .default, handler: {action in |
| | | // let settingUrl = NSURL(string: UIApplication.openSettingsURLString)! |
| | | // if UIApplication.shared.canOpenURL(settingUrl as URL){ |
| | | // if #available(iOS 10.0, *) { |
| | | // UIApplication.shared.open(settingUrl as URL, options: [:], completionHandler: nil) |
| | | // } else { |
| | | // UIApplication.shared.openURL(settingUrl as URL) |
| | | // } |
| | | // } |
| | | // }) |
| | | // |
| | | // alertController.addAction(cancelAction) |
| | | // alertController.addAction(okAction) |
| | | // self.present(alertController, animated: true, completion: nil) |
| | | // } else { |
| | | // |
| | | // } |
| | | // |
| | | // }else{ |
| | | // setupCaptureSession() |
| | | // addSubviews() |
| | | // scanTimer = Timer.scheduledTimer(timeInterval: 3.0, target: self, selector: #selector(startAnimation), userInfo: nil, repeats: true) |
| | | // } |
| | | } |
| | | |
| | | private func limitSuccess(){ |
| | |
| | | |
| | | func addSubviews() { |
| | | let _: CGFloat = (UIScreen.main.bounds.size.width - borderWidth) * 0.5 |
| | | |
| | | // |
| | | |
| | | // let coverImageView = UIImageView(frame: CGRect(x: 0, y: 64, width: UIScreen.main.bounds.size.width, height: UIScreen.main.bounds.size.height - 64)) |
| | | // coverImageView.backgroundColor = UIColor.clear |
| | | // coverImageView.image = self.getCoverView(left: leftMargin, top: topMargin) |
| | | // view.addSubview(coverImageView) |
| | | |
| | | |
| | | |
| | | //扫描边框 |
| | | borderView!.frame = CGRect.init(x: (UIScreen.main.bounds.size.width-(self.view.center.x+30))/2, y: (UIScreen.main.bounds.size.height-(self.view.center.x + 30))/2, width: self.view.center.x + 30, height: self.view.center.x + 30) |