ScanHelper.swift 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. //
  2. // ScanHelper.swift
  3. // O2Platform
  4. //
  5. // Created by FancyLou on 2018/9/30.
  6. // Copyright © 2018 zoneland. All rights reserved.
  7. //
  8. import AVFoundation
  9. import swiftScan
  10. class ScanHelper {
  11. /// 生成扫码的ViewController 如果没有权限就返回nil
  12. static func initScanViewController() -> NewScanViewController? {
  13. // 权限判断
  14. let status = AVCaptureDevice.authorizationStatus(for: .video)
  15. if status == .denied || status == .restricted {
  16. ProgressHUD.showError("没有摄像头权限,请先开启!")
  17. return nil
  18. }else {
  19. let scanVC = NewScanViewController()
  20. var scanStyle = LBXScanViewStyle()
  21. scanStyle.centerUpOffset = 44;
  22. scanStyle.photoframeAngleStyle = LBXScanViewPhotoframeAngleStyle.Inner;
  23. scanStyle.photoframeLineW = 2;
  24. scanStyle.photoframeAngleW = 18;
  25. scanStyle.photoframeAngleH = 18;
  26. scanStyle.isNeedShowRetangle = false;
  27. scanStyle.anmiationStyle = LBXScanViewAnimationStyle.LineMove;
  28. //scanStyle.colorAngle = UIColor(red: 0.0/255, green: 200.0/255.0, blue: 20.0/255.0, alpha: 1.0)
  29. scanStyle.colorAngle = base_color
  30. scanStyle.animationImage = UIImage(named: "qrcode_scan_part_net.png")
  31. scanVC.scanStyle = scanStyle
  32. return scanVC
  33. }
  34. }
  35. }