582f536d
yangbin
common:2022.1.28
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
//
// ScanViewController.swift
// Twear
//
// Created by yangbin on 2022/1/19.
//
import UIKit
import swiftScan
import SnapKit
class ScanViewController: LBXScanViewController {
var isOpenedFlash: Bool = false
lazy var flashButton: UIButton = {
let button = UIButton()
// button.backgroundColor = .red
button.setImage(UIImage(named: "scan_flash_off"), for: .normal)
button.addTarget(self, action: #selector(openOrCloseFlash), for: .touchUpInside)
return button
}()
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
self.navigationController?.setNavigationBarHidden(false, animated: true)
|
be19e595
yangbin
9
|
27
|
// self.navigationController?.navigationBar.isTranslucent = false
|
582f536d
yangbin
common:2022.1.28
|
28
29
30
31
32
33
|
}
override func viewDidLoad() {
super.viewDidLoad()
// view.backgroundColor = .white
title = LocString("扫码连接")
|
be19e595
yangbin
9
|
34
35
36
37
38
39
40
41
|
// guard let statusBarWindow = UIApplication.shared.value(forKeyPath: "statusBarWindow") as? UIView else { return }
// guard let statusBar = UIApplication.shared.value(forKeyPath: "statusBar") as? UIView else { return }
// if statusBar.responds(to: #select(setter: UIView.bac))
// statusBar.backgroundColor = .green
// let statusBarview = UIView(frame: CGRect(x: 0, y: 0, width: SCREEN_WIDTH, height: StatusBarHeight))
// statusBarview.backgroundColor = .green
// navigationController?.navigationBar.addSubview(statusBarview)
|
582f536d
yangbin
common:2022.1.28
|
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
|
// let y = view.frame.size.height / 2.0 + (view.frame.size.width - 120) / 2.0 - 44
drawScanView()
view.addSubview(flashButton)
flashButton.snp.makeConstraints { make in
make.width.height.equalTo(50)
make.centerX.equalToSuperview()
make.centerY.equalToSuperview().offset((SCREEN_WIDTH-120)/2-44-25)
// make.top.equalToSuperview().offset(y)
// make.bottom.equalTo(qRScanView!.snp.bottom)
}
// Do any additional setup after loading the view.
}
@objc func openOrCloseFlash() {
scanObj?.changeTorch()
isOpenedFlash = !isOpenedFlash
if isOpenedFlash {
flashButton.setImage(UIImage(named: "scan_flash_on"), for:UIControl.State.normal)
} else {
flashButton.setImage(UIImage(named: "scan_flash_off"), for:UIControl.State.normal)
}
}
// func scanFinished(scanResult: LBXScanResult, error: String?) {
// print(scanResult.strScanned)
// }
/*
// MARK: - Navigation
// In a storyboard-based application, you will often want to do a little preparation before navigation
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
// Get the new view controller using segue.destination.
// Pass the selected object to the new view controller.
}
*/
}
|