ScanHelper.swift 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  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. import ProgressHUDSwift
  11. class ScanHelper {
  12. /// 生成扫码的ViewController 如果没有权限就返回nil
  13. static func initScanViewController() -> NewScanViewController? {
  14. // 权限判断
  15. let status = AVCaptureDevice.authorizationStatus(for: .video)
  16. if status == .denied || status == .restricted {
  17. ProgressSHD.showError("没有摄像头权限,请先开启!")
  18. return nil
  19. }else {
  20. let scanVC = NewScanViewController()
  21. var scanStyle = LBXScanViewStyle()
  22. scanStyle.centerUpOffset = 44;
  23. scanStyle.photoframeAngleStyle = LBXScanViewPhotoframeAngleStyle.Inner;
  24. scanStyle.photoframeLineW = 2;
  25. scanStyle.photoframeAngleW = 18;
  26. scanStyle.photoframeAngleH = 18;
  27. scanStyle.isNeedShowRetangle = false;
  28. scanStyle.anmiationStyle = LBXScanViewAnimationStyle.LineMove;
  29. //scanStyle.colorAngle = UIColor(red: 0.0/255, green: 200.0/255.0, blue: 20.0/255.0, alpha: 1.0)
  30. scanStyle.colorAngle = base_color
  31. scanStyle.animationImage = UIImage(named: "qrcode_scan_part_net.png")
  32. scanVC.scanStyle = scanStyle
  33. return scanVC
  34. }
  35. }
  36. }