├── .gitignore
├── LICENSE
├── Pictures
├── sgqrcode_1.png
├── sgqrcode_2.png
├── sgqrcode_3.png
├── sgqrcode_4.png
├── sgqrcode_5.png
└── sgqrcode_6.png
├── README.md
├── SGQRCode.podspec
├── SGQRCode
├── Permission
│ ├── SGPermission.h
│ ├── SGPermission.m
│ ├── SGPermissionCamera.h
│ ├── SGPermissionCamera.m
│ ├── SGPermissionPhoto.h
│ └── SGPermissionPhoto.m
├── QRCode
│ ├── SGGenerateQRCode.h
│ ├── SGGenerateQRCode.m
│ ├── SGScanCode.h
│ ├── SGScanCode.m
│ └── SGScanCodeDelegate.h
├── SGQRCode.bundle
│ ├── Root.plist
│ ├── en.lproj
│ │ └── Root.strings
│ ├── scan_end_sound.caf
│ ├── scan_scanline@2x.png
│ ├── scan_scanline@3x.png
│ ├── scan_scanline_qq.png
│ ├── scan_scanline_wb@2x.png
│ ├── scan_scanline_wb@3x.png
│ └── scan_scanline_wc.png
├── SGQRCode.h
├── SGQRCodeLog.h
├── SGQRCodeLog.m
├── ScanView
│ ├── SGScanView.h
│ ├── SGScanView.m
│ ├── SGScanViewConfigure.h
│ └── SGScanViewConfigure.m
├── SoundEffect
│ ├── SGSoundEffect.h
│ └── SGSoundEffect.m
├── Torch
│ ├── SGTorch.h
│ └── SGTorch.m
└── WeakProxy
│ ├── SGWeakProxy.h
│ └── SGWeakProxy.m
├── SGQRCodeExample.xcodeproj
├── project.pbxproj
└── project.xcworkspace
│ ├── contents.xcworkspacedata
│ └── xcshareddata
│ └── IDEWorkspaceChecks.plist
├── SGQRCodeExample
├── AppDelegate.h
├── AppDelegate.m
├── Assets.xcassets
│ ├── AppIcon.appiconset
│ │ ├── Contents.json
│ │ ├── icon.png
│ │ ├── icon10240x10240.png
│ │ ├── icon57x57@2x.png
│ │ ├── icon60x60@2x.png
│ │ └── icon60x60@3x.png
│ ├── Contents.json
│ ├── bg_image.imageset
│ │ ├── Contents.json
│ │ └── bg_image@2x.png
│ └── wc
│ │ ├── Contents.json
│ │ ├── wc_scan_album.imageset
│ │ ├── Contents.json
│ │ ├── wc_scan_album.png
│ │ ├── wc_scan_album@2x.png
│ │ └── wc_scan_album@3x.png
│ │ ├── wc_scan_mine_qrcode.imageset
│ │ ├── Contents.json
│ │ ├── wc_scan_mine_qrcode.png
│ │ ├── wc_scan_mine_qrcode@2x.png
│ │ └── wc_scan_mine_qrcode@3x.png
│ │ ├── wc_scan_torch.imageset
│ │ ├── Contents.json
│ │ └── wc_scan_torch.png
│ │ └── wc_scan_torch_hl.imageset
│ │ ├── Contents.json
│ │ └── wc_scan_torch_hl.png
├── Base.lproj
│ └── LaunchScreen.storyboard
├── Info.plist
├── Main.storyboard
├── MyQRCode
│ ├── MyQRCodeVC.h
│ └── MyQRCodeVC.m
├── QQ
│ └── Controller
│ │ ├── QQQRCodeVC.h
│ │ └── QQQRCodeVC.m
├── ViewController.h
├── ViewController.m
├── WB
│ └── Controller
│ │ ├── WBQRCodeVC.h
│ │ └── WBQRCodeVC.m
├── WC
│ ├── Controller
│ │ ├── WCQRCodeVC.h
│ │ └── WCQRCodeVC.m
│ └── View
│ │ ├── WCToolBar.h
│ │ └── WCToolBar.m
├── WebView
│ ├── WebViewController.h
│ └── WebViewController.m
├── XC
│ └── Controller
│ │ ├── XCQRCodeVC.h
│ │ └── XCQRCodeVC.m
└── main.m
├── SGQRCodeExampleTests
├── Info.plist
└── SGQRCodeExampleTests.m
└── SGQRCodeExampleUITests
├── Info.plist
└── SGQRCodeExampleUITests.m
/.gitignore:
--------------------------------------------------------------------------------
1 | # Xcode
2 | #
3 | # gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore
4 |
5 | ## Build generated
6 | build/
7 | DerivedData/
8 |
9 | ## Various settings
10 | *.pbxuser
11 | !default.pbxuser
12 | *.mode1v3
13 | !default.mode1v3
14 | *.mode2v3
15 | !default.mode2v3
16 | *.perspectivev3
17 | !default.perspectivev3
18 | xcuserdata/
19 |
20 | ## Other
21 | *.moved-aside
22 | *.xcuserstate
23 |
24 | ## Obj-C/Swift specific
25 | *.hmap
26 | *.ipa
27 | *.dSYM.zip
28 | *.dSYM
29 |
30 | # CocoaPods
31 | #
32 | # We recommend against adding the Pods directory to your .gitignore. However
33 | # you should judge for yourself, the pros and cons are mentioned at:
34 | # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
35 | #
36 | # Pods/
37 |
38 | # Carthage
39 | #
40 | # Add this line if you want to avoid checking in source code from Carthage dependencies.
41 | # Carthage/Checkouts
42 |
43 | Carthage/Build
44 |
45 | # fastlane
46 | #
47 | # It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the
48 | # screenshots whenever they are needed.
49 | # For more information about the recommended setup visit:
50 | # https://github.com/fastlane/fastlane/blob/master/fastlane/docs/Gitignore.md
51 |
52 | fastlane/report.xml
53 | fastlane/screenshots
54 |
55 | #Code Injection
56 | #
57 | # After new code Injection tools there's a generated folder /iOSInjectionProject
58 | # https://github.com/johnno1962/injectionforxcode
59 |
60 | iOSInjectionProject/
61 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | Apache License
2 | Version 2.0, January 2004
3 | http://www.apache.org/licenses/
4 |
5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6 |
7 | 1. Definitions.
8 |
9 | "License" shall mean the terms and conditions for use, reproduction,
10 | and distribution as defined by Sections 1 through 9 of this document.
11 |
12 | "Licensor" shall mean the copyright owner or entity authorized by
13 | the copyright owner that is granting the License.
14 |
15 | "Legal Entity" shall mean the union of the acting entity and all
16 | other entities that control, are controlled by, or are under common
17 | control with that entity. For the purposes of this definition,
18 | "control" means (i) the power, direct or indirect, to cause the
19 | direction or management of such entity, whether by contract or
20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the
21 | outstanding shares, or (iii) beneficial ownership of such entity.
22 |
23 | "You" (or "Your") shall mean an individual or Legal Entity
24 | exercising permissions granted by this License.
25 |
26 | "Source" form shall mean the preferred form for making modifications,
27 | including but not limited to software source code, documentation
28 | source, and configuration files.
29 |
30 | "Object" form shall mean any form resulting from mechanical
31 | transformation or translation of a Source form, including but
32 | not limited to compiled object code, generated documentation,
33 | and conversions to other media types.
34 |
35 | "Work" shall mean the work of authorship, whether in Source or
36 | Object form, made available under the License, as indicated by a
37 | copyright notice that is included in or attached to the work
38 | (an example is provided in the Appendix below).
39 |
40 | "Derivative Works" shall mean any work, whether in Source or Object
41 | form, that is based on (or derived from) the Work and for which the
42 | editorial revisions, annotations, elaborations, or other modifications
43 | represent, as a whole, an original work of authorship. For the purposes
44 | of this License, Derivative Works shall not include works that remain
45 | separable from, or merely link (or bind by name) to the interfaces of,
46 | the Work and Derivative Works thereof.
47 |
48 | "Contribution" shall mean any work of authorship, including
49 | the original version of the Work and any modifications or additions
50 | to that Work or Derivative Works thereof, that is intentionally
51 | submitted to Licensor for inclusion in the Work by the copyright owner
52 | or by an individual or Legal Entity authorized to submit on behalf of
53 | the copyright owner. For the purposes of this definition, "submitted"
54 | means any form of electronic, verbal, or written communication sent
55 | to the Licensor or its representatives, including but not limited to
56 | communication on electronic mailing lists, source code control systems,
57 | and issue tracking systems that are managed by, or on behalf of, the
58 | Licensor for the purpose of discussing and improving the Work, but
59 | excluding communication that is conspicuously marked or otherwise
60 | designated in writing by the copyright owner as "Not a Contribution."
61 |
62 | "Contributor" shall mean Licensor and any individual or Legal Entity
63 | on behalf of whom a Contribution has been received by Licensor and
64 | subsequently incorporated within the Work.
65 |
66 | 2. Grant of Copyright License. Subject to the terms and conditions of
67 | this License, each Contributor hereby grants to You a perpetual,
68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69 | copyright license to reproduce, prepare Derivative Works of,
70 | publicly display, publicly perform, sublicense, and distribute the
71 | Work and such Derivative Works in Source or Object form.
72 |
73 | 3. Grant of Patent License. Subject to the terms and conditions of
74 | this License, each Contributor hereby grants to You a perpetual,
75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76 | (except as stated in this section) patent license to make, have made,
77 | use, offer to sell, sell, import, and otherwise transfer the Work,
78 | where such license applies only to those patent claims licensable
79 | by such Contributor that are necessarily infringed by their
80 | Contribution(s) alone or by combination of their Contribution(s)
81 | with the Work to which such Contribution(s) was submitted. If You
82 | institute patent litigation against any entity (including a
83 | cross-claim or counterclaim in a lawsuit) alleging that the Work
84 | or a Contribution incorporated within the Work constitutes direct
85 | or contributory patent infringement, then any patent licenses
86 | granted to You under this License for that Work shall terminate
87 | as of the date such litigation is filed.
88 |
89 | 4. Redistribution. You may reproduce and distribute copies of the
90 | Work or Derivative Works thereof in any medium, with or without
91 | modifications, and in Source or Object form, provided that You
92 | meet the following conditions:
93 |
94 | (a) You must give any other recipients of the Work or
95 | Derivative Works a copy of this License; and
96 |
97 | (b) You must cause any modified files to carry prominent notices
98 | stating that You changed the files; and
99 |
100 | (c) You must retain, in the Source form of any Derivative Works
101 | that You distribute, all copyright, patent, trademark, and
102 | attribution notices from the Source form of the Work,
103 | excluding those notices that do not pertain to any part of
104 | the Derivative Works; and
105 |
106 | (d) If the Work includes a "NOTICE" text file as part of its
107 | distribution, then any Derivative Works that You distribute must
108 | include a readable copy of the attribution notices contained
109 | within such NOTICE file, excluding those notices that do not
110 | pertain to any part of the Derivative Works, in at least one
111 | of the following places: within a NOTICE text file distributed
112 | as part of the Derivative Works; within the Source form or
113 | documentation, if provided along with the Derivative Works; or,
114 | within a display generated by the Derivative Works, if and
115 | wherever such third-party notices normally appear. The contents
116 | of the NOTICE file are for informational purposes only and
117 | do not modify the License. You may add Your own attribution
118 | notices within Derivative Works that You distribute, alongside
119 | or as an addendum to the NOTICE text from the Work, provided
120 | that such additional attribution notices cannot be construed
121 | as modifying the License.
122 |
123 | You may add Your own copyright statement to Your modifications and
124 | may provide additional or different license terms and conditions
125 | for use, reproduction, or distribution of Your modifications, or
126 | for any such Derivative Works as a whole, provided Your use,
127 | reproduction, and distribution of the Work otherwise complies with
128 | the conditions stated in this License.
129 |
130 | 5. Submission of Contributions. Unless You explicitly state otherwise,
131 | any Contribution intentionally submitted for inclusion in the Work
132 | by You to the Licensor shall be under the terms and conditions of
133 | this License, without any additional terms or conditions.
134 | Notwithstanding the above, nothing herein shall supersede or modify
135 | the terms of any separate license agreement you may have executed
136 | with Licensor regarding such Contributions.
137 |
138 | 6. Trademarks. This License does not grant permission to use the trade
139 | names, trademarks, service marks, or product names of the Licensor,
140 | except as required for reasonable and customary use in describing the
141 | origin of the Work and reproducing the content of the NOTICE file.
142 |
143 | 7. Disclaimer of Warranty. Unless required by applicable law or
144 | agreed to in writing, Licensor provides the Work (and each
145 | Contributor provides its Contributions) on an "AS IS" BASIS,
146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147 | implied, including, without limitation, any warranties or conditions
148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149 | PARTICULAR PURPOSE. You are solely responsible for determining the
150 | appropriateness of using or redistributing the Work and assume any
151 | risks associated with Your exercise of permissions under this License.
152 |
153 | 8. Limitation of Liability. In no event and under no legal theory,
154 | whether in tort (including negligence), contract, or otherwise,
155 | unless required by applicable law (such as deliberate and grossly
156 | negligent acts) or agreed to in writing, shall any Contributor be
157 | liable to You for damages, including any direct, indirect, special,
158 | incidental, or consequential damages of any character arising as a
159 | result of this License or out of the use or inability to use the
160 | Work (including but not limited to damages for loss of goodwill,
161 | work stoppage, computer failure or malfunction, or any and all
162 | other commercial damages or losses), even if such Contributor
163 | has been advised of the possibility of such damages.
164 |
165 | 9. Accepting Warranty or Additional Liability. While redistributing
166 | the Work or Derivative Works thereof, You may choose to offer,
167 | and charge a fee for, acceptance of support, warranty, indemnity,
168 | or other liability obligations and/or rights consistent with this
169 | License. However, in accepting such obligations, You may act only
170 | on Your own behalf and on Your sole responsibility, not on behalf
171 | of any other Contributor, and only if You agree to indemnify,
172 | defend, and hold each Contributor harmless for any liability
173 | incurred by, or claims asserted against, such Contributor by reason
174 | of your accepting any such warranty or additional liability.
175 |
176 | END OF TERMS AND CONDITIONS
177 |
178 | APPENDIX: How to apply the Apache License to your work.
179 |
180 | To apply the Apache License to your work, attach the following
181 | boilerplate notice, with the fields enclosed by brackets "{}"
182 | replaced with your own identifying information. (Don't include
183 | the brackets!) The text should be enclosed in the appropriate
184 | comment syntax for the file format. We also recommend that a
185 | file or class name and description of purpose be included on the
186 | same "printed page" as the copyright notice for easier
187 | identification within third-party archives.
188 |
189 | Copyright {yyyy} {name of copyright owner}
190 |
191 | Licensed under the Apache License, Version 2.0 (the "License");
192 | you may not use this file except in compliance with the License.
193 | You may obtain a copy of the License at
194 |
195 | http://www.apache.org/licenses/LICENSE-2.0
196 |
197 | Unless required by applicable law or agreed to in writing, software
198 | distributed under the License is distributed on an "AS IS" BASIS,
199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200 | See the License for the specific language governing permissions and
201 | limitations under the License.
202 |
--------------------------------------------------------------------------------
/Pictures/sgqrcode_1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kingsic/SGQRCode/41f0640ba8b1e29576121acab72635a7c9c52d17/Pictures/sgqrcode_1.png
--------------------------------------------------------------------------------
/Pictures/sgqrcode_2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kingsic/SGQRCode/41f0640ba8b1e29576121acab72635a7c9c52d17/Pictures/sgqrcode_2.png
--------------------------------------------------------------------------------
/Pictures/sgqrcode_3.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kingsic/SGQRCode/41f0640ba8b1e29576121acab72635a7c9c52d17/Pictures/sgqrcode_3.png
--------------------------------------------------------------------------------
/Pictures/sgqrcode_4.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kingsic/SGQRCode/41f0640ba8b1e29576121acab72635a7c9c52d17/Pictures/sgqrcode_4.png
--------------------------------------------------------------------------------
/Pictures/sgqrcode_5.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kingsic/SGQRCode/41f0640ba8b1e29576121acab72635a7c9c52d17/Pictures/sgqrcode_5.png
--------------------------------------------------------------------------------
/Pictures/sgqrcode_6.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kingsic/SGQRCode/41f0640ba8b1e29576121acab72635a7c9c52d17/Pictures/sgqrcode_6.png
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 |
2 | # SGQRCode
3 |
4 | | Version | UIKit | Use |
5 | |:-----:|:-----:|:-----:|
6 | | 3.5x | iOS 9.0+ | Block
7 | | 4.x | iOS 11.0+ | Delegate
8 |
9 | * QQ群:825339547
10 |
11 | * [3.5.1版本 API 使用说明](https://github.com/kingsic/SGQRCode/wiki/3.5.1版本API说明)
12 |
13 |
14 | ## 主要功能
15 |
16 | `生成二维码`
17 |
18 | `扫描二维码`
19 |
20 | `捕获内容缩放功能`
21 |
22 | `图片中识别二维码`
23 |
24 | `相机、相册权限判断`
25 |
26 | `根据光线强弱开启关闭手电筒`
27 |
28 | `扫描成功后界面间的逻辑跳转处理`
29 |
30 | `扫描界面可高度自定义(满足所有主流app)`
31 |
32 |
33 | ## 主要类说明
34 | | 类名 | 说明 |
35 | |-----|-----|
36 | | SGScanCode | 扫描二维码 |
37 | | SGScanViewConfigure | 扫描视图配置 |
38 | | SGScanView | 扫描视图 |
39 | | SGPermission | 相册、相机权限管理 |
40 | | SGTorch | 手电筒管理 |
41 | | SGQRCodeLog | 调试日志 |
42 |
43 |
44 | ## SGQRCode 集成流程
45 |
46 | **手动集成**
47 |
48 | `添加 SGQRCode 文件夹到工程中`
49 |
50 | **通过 CocoaPods 集成**
51 |
52 | `pod 'SGQRCode', '~> 4.1.0'`
53 |
54 |
55 | **Info.plist 添加以下字段**
56 |
57 | `NSCameraUsageDescription (相机权限访问)`
58 |
59 | `NSPhotoLibraryUsageDescription (相册权限访问)`
60 |
61 |
62 | **引用头文件**
63 |
64 | `#import `
65 |
66 |
67 | **扫描二维码相关代码**
68 | ```Objective-C
69 | // 创建二维码扫描类
70 | scanCode = [SGScanCode scanCode];
71 |
72 | // 预览视图,必须设置
73 | scanCode.preview = self.view;
74 |
75 | // 遵循 SGScanCodeDelegate
76 | scanCode.delegate = self;
77 |
78 | // 遵循 SGScanCodeSampleBufferDelegate
79 | scanCode.sampleBufferDelegate = self;
80 |
81 | // 开启扫描
82 | [scanCode startRunning];
83 |
84 | // 结束扫描
85 | [scanCode stopRunning];
86 | ```
87 |
88 | **Delegate 方法**
89 | ```Objective-C
90 | // SGScanCodeDelegate
91 | - (void)scanCode:(SGScanCode *)scanCode result:(NSString *)result {
92 | <#code#>
93 | }
94 |
95 | // SGScanCodeSampleBufferDelegate
96 | - (void)scanCode:(SGScanCode *)scanCode brightness:(CGFloat)brightness {
97 | <#code#>
98 | }
99 | ```
100 |
101 | **图片中识别二维码方法**
102 | ```Objective-C
103 | [scanCode readQRCode:image completion:^(NSString *result) {
104 | <#code#>
105 | }];
106 | ```
107 |
108 | **生成二维码相关方法**
109 | ```Objective-C
110 | // 普通二维码生成方法
111 | [SGGenerateQRCode generateQRCodeWithData:data size:size];
112 |
113 | // 带 logo 的二维码生成方法
114 | [SGGenerateQRCode generateQRCodeWithData:data size:size logoImage:logoImage ratio:ratio];
115 | ```
116 |
117 |
118 | ## 效果图
119 |
120 |
121 |
122 |
123 |
124 |
125 | ## 问题及解决方案
126 |
127 | * 若在使用 CocoaPods 安装第三方时,出现 [!] Unable to find a specification for SGQRCode 提示时,打开终端先输入 pod repo remove master;执行完毕后再输入 pod setup 即可 (可能会等待一段时间)
128 |
129 | * CIDetector 类只能识别图片中的二维码,目前暂不支持识别图片中的条形码 [解决方案](https://juejin.cn/post/6844903910428114952l)
130 |
131 |
132 | ## 更新说明
133 |
134 | * 2021-07-05 :v3.5.1 版本重构:修复 [#163](https://github.com/kingsic/SGQRCode/issues/163) 问题,更多内容请在 [releases](https://github.com/kingsic/SGQRCode/releases/tag/3.5.1) 中查看
135 |
136 | * 2022-07-16 :v4.0.0 版本重构:Delegate 取代 Block,新增手动对焦功能,优化拓展扫描视图,更多内容请在 [releases](https://github.com/kingsic/SGQRCode/releases/tag/4.0.0) 中查看
137 |
138 | * 2022-07-16 :v4.1.0 优化SGScanView内部代码逻辑,修复无扫描线时,导致程序崩溃问题
139 |
140 |
141 | ## License
142 | SGQRCode is released under the Apache License 2.0. See [LICENSE](https://github.com/kingsic/SGQRCode/blob/master/LICENSE) for details.
143 |
--------------------------------------------------------------------------------
/SGQRCode.podspec:
--------------------------------------------------------------------------------
1 |
2 | Pod::Spec.new do |s|
3 | s.name = 'SGQRCode'
4 | s.version = '4.1.0'
5 | s.summary = 'The easy to use bar code and QR code scan library for iOS'
6 | s.homepage = 'https://github.com/kingsic/SGQRCode'
7 | s.license = 'Apache-2.0'
8 | s.authors = {'kingsic' => 'kingsic@126.com'}
9 | s.platform = :ios, '11.0'
10 | s.source = {:git => 'https://github.com/kingsic/SGQRCode.git', :tag => s.version}
11 | s.source_files = 'SGQRCode/**/*.{h,m}'
12 | s.resource = 'SGQRCode/SGQRCode.bundle'
13 | s.requires_arc = true
14 | end
15 |
--------------------------------------------------------------------------------
/SGQRCode/Permission/SGPermission.h:
--------------------------------------------------------------------------------
1 | //
2 | // SGPermission.h
3 | // SGQRCodeExample
4 | //
5 | // Created by kingsic on 2022/7/8.
6 | // Copyright © 2022 kingsic. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @class SGPermission;
12 |
13 | typedef enum : NSUInteger {
14 | /// 相机
15 | SGPermissionTypeCamera,
16 | /// 相册
17 | SGPermissionTypePhoto,
18 | } SGPermissionType;
19 |
20 | typedef enum : NSUInteger {
21 | /// 未授权
22 | SGPermissionStatusNotDetermined,
23 | /// 已授权
24 | SGPermissionStatusAuthorized,
25 | /// 已拒绝
26 | SGPermissionStatusDenied,
27 | /// 受限制
28 | SGPermissionStatusRestricted,
29 | } SGPermissionStatus;
30 |
31 | NS_ASSUME_NONNULL_BEGIN
32 |
33 | typedef void(^SGPermissionBlock)(SGPermission *permission, SGPermissionStatus status);
34 |
35 | @interface SGPermission : NSObject
36 | /// 对象方法获取权限状态
37 | ///
38 | /// @param type 权限类型
39 | /// @param block 权限状态回调
40 | - (void)initWithType:(SGPermissionType)type completion:(SGPermissionBlock)block;
41 |
42 | /// 类方法获取权限状态
43 | ///
44 | /// @param type 权限类型
45 | /// @param block 权限状态回调
46 | + (void)permissionWithType:(SGPermissionType)type completion:(SGPermissionBlock)block;
47 |
48 | /// 权限状态为:SGPermissionStatusNotDetermined时,需请求授权
49 | - (void)request:(void (^)(BOOL granted))handler;
50 |
51 | @end
52 |
53 | NS_ASSUME_NONNULL_END
54 |
--------------------------------------------------------------------------------
/SGQRCode/Permission/SGPermission.m:
--------------------------------------------------------------------------------
1 | //
2 | // SGPermission.m
3 | // SGQRCodeExample
4 | //
5 | // Created by kingsic on 2022/7/8.
6 | // Copyright © 2022 kingsic. All rights reserved.
7 | //
8 |
9 | #import "SGPermission.h"
10 | #import "SGPermissionCamera.h"
11 | #import "SGPermissionPhoto.h"
12 |
13 | @interface SGPermission ()
14 | @property (nonatomic, assign) SGPermissionType type;
15 | @end
16 |
17 | @implementation SGPermission
18 |
19 | - (void)initWithType:(SGPermissionType)type completion:(SGPermissionBlock)block {
20 | [SGPermission permissionWithType:type completion:block];
21 | }
22 |
23 | + (void)permissionWithType:(SGPermissionType)type completion:(SGPermissionBlock)block {
24 | SGPermission *permission = [[SGPermission alloc] init];
25 | permission.type = type;
26 |
27 | if (type == SGPermissionTypeCamera) {
28 | [SGPermissionCamera camera:^(SGPermissionCamera * _Nonnull camera, SGPermissionStatus status) {
29 | if (block) {
30 | block(permission, status);
31 | }
32 | }];
33 | } else if (type == SGPermissionTypePhoto) {
34 | [SGPermissionPhoto photo:^(SGPermissionPhoto * _Nonnull photos, SGPermissionStatus status) {
35 | if (block) {
36 | block(permission, status);
37 | }
38 | }];
39 | }
40 | }
41 |
42 | - (void)request:(void (^)(BOOL))handler {
43 | if (self.type == SGPermissionTypeCamera) {
44 | [SGPermissionCamera request:handler];
45 | } else if (self.type == SGPermissionTypePhoto) {
46 | [SGPermissionPhoto request:handler];
47 | }
48 | }
49 |
50 | @end
51 |
--------------------------------------------------------------------------------
/SGQRCode/Permission/SGPermissionCamera.h:
--------------------------------------------------------------------------------
1 | //
2 | // SGPermissionCamera.h
3 | // SGQRCodeExample
4 | //
5 | // Created by kingsic on 2022/7/8.
6 | // Copyright © 2022 kingsic. All rights reserved.
7 | //
8 |
9 | #import
10 | #import "SGPermission.h"
11 |
12 | @class SGPermissionCamera;
13 |
14 | NS_ASSUME_NONNULL_BEGIN
15 |
16 | typedef void(^SGPermissionCameraBlock)(SGPermissionCamera *camera, SGPermissionStatus status);
17 |
18 | @interface SGPermissionCamera : NSObject
19 | + (void)camera:(SGPermissionCameraBlock)block;
20 | + (void)request:(void (^)(BOOL granted))handler;
21 | @end
22 |
23 | NS_ASSUME_NONNULL_END
24 |
--------------------------------------------------------------------------------
/SGQRCode/Permission/SGPermissionCamera.m:
--------------------------------------------------------------------------------
1 | //
2 | // SGPermissionCamera.m
3 | // SGQRCodeExample
4 | //
5 | // Created by kingsic on 2022/7/8.
6 | // Copyright © 2022 kingsic. All rights reserved.
7 | //
8 |
9 | #import "SGPermissionCamera.h"
10 | #import
11 |
12 | @implementation SGPermissionCamera
13 |
14 | + (void)camera:(SGPermissionCameraBlock)block {
15 | SGPermissionCamera *camera = [[SGPermissionCamera alloc] init];
16 |
17 | AVAuthorizationStatus status = [AVCaptureDevice authorizationStatusForMediaType:AVMediaTypeVideo];
18 | if (status == AVAuthorizationStatusNotDetermined) {
19 | if (block) {
20 | block(camera, SGPermissionStatusNotDetermined);
21 | }
22 | } else if (status == AVAuthorizationStatusAuthorized) {
23 | if (block) {
24 | block(camera, SGPermissionStatusAuthorized);
25 | }
26 | } else if (status == AVAuthorizationStatusDenied) {
27 | if (block) {
28 | block(camera, SGPermissionStatusDenied);
29 | }
30 | } else if (status == AVAuthorizationStatusRestricted) {
31 | if (block) {
32 | block(camera, SGPermissionStatusRestricted);
33 | }
34 | }
35 | }
36 |
37 | + (void)request:(void (^)(BOOL granted))handler {
38 | [AVCaptureDevice requestAccessForMediaType:AVMediaTypeVideo completionHandler:^(BOOL granted) {
39 | if (granted) {
40 | dispatch_async(dispatch_get_main_queue(), ^{
41 | handler(YES);
42 | });
43 | } else {
44 | dispatch_async(dispatch_get_main_queue(), ^{
45 | handler(NO);
46 | });
47 | }
48 | }];
49 | }
50 |
51 | @end
52 |
--------------------------------------------------------------------------------
/SGQRCode/Permission/SGPermissionPhoto.h:
--------------------------------------------------------------------------------
1 | //
2 | // SGPermissionPhoto.h
3 | // SGQRCodeExample
4 | //
5 | // Created by kingsic on 2022/7/8.
6 | // Copyright © 2022 kingsic. All rights reserved.
7 | //
8 |
9 | #import
10 | #import "SGPermission.h"
11 |
12 | @class SGPermissionPhoto;
13 |
14 | NS_ASSUME_NONNULL_BEGIN
15 |
16 | typedef void(^SGPermissionPhotoBlock)(SGPermissionPhoto *photos, SGPermissionStatus status);
17 |
18 | @interface SGPermissionPhoto : NSObject
19 | + (void)photo:(SGPermissionPhotoBlock)block;
20 | + (void)request:(void (^)(BOOL granted))handler;
21 | @end
22 |
23 | NS_ASSUME_NONNULL_END
24 |
--------------------------------------------------------------------------------
/SGQRCode/Permission/SGPermissionPhoto.m:
--------------------------------------------------------------------------------
1 | //
2 | // SGPermissionPhoto.m
3 | // SGQRCodeExample
4 | //
5 | // Created by kingsic on 2022/7/8.
6 | // Copyright © 2022 kingsic. All rights reserved.
7 | //
8 |
9 | #import "SGPermissionPhoto.h"
10 | #import
11 |
12 | @implementation SGPermissionPhoto
13 |
14 | + (void)photo:(SGPermissionPhotoBlock)block {
15 | SGPermissionPhoto *photo = [[SGPermissionPhoto alloc] init];
16 |
17 | PHAuthorizationStatus status = [PHPhotoLibrary authorizationStatus];
18 | if (status == PHAuthorizationStatusNotDetermined) {
19 | dispatch_async(dispatch_get_main_queue(), ^{
20 | if (block) {
21 | block(photo, SGPermissionStatusNotDetermined);
22 | }
23 | });
24 | } else if (status == PHAuthorizationStatusAuthorized) {
25 | if (block) {
26 | block(photo, SGPermissionStatusAuthorized);
27 | }
28 | } else if (status == PHAuthorizationStatusDenied) {
29 | if (block) {
30 | block(photo, SGPermissionStatusDenied);
31 | }
32 | } else if (status == PHAuthorizationStatusRestricted) {
33 | if (block) {
34 | block(photo, SGPermissionStatusRestricted);
35 | }
36 | }
37 | }
38 |
39 | + (void)request:(void (^)(BOOL granted))handler {
40 | [PHPhotoLibrary requestAuthorization:^(PHAuthorizationStatus status) {
41 | if (status == PHAuthorizationStatusAuthorized) {
42 | dispatch_async(dispatch_get_main_queue(), ^{
43 | handler(YES);
44 | });
45 | } else {
46 | dispatch_async(dispatch_get_main_queue(), ^{
47 | handler(NO);
48 | });
49 | }
50 | }];
51 | }
52 |
53 | @end
54 |
--------------------------------------------------------------------------------
/SGQRCode/QRCode/SGGenerateQRCode.h:
--------------------------------------------------------------------------------
1 | //
2 | // SGGenerateQRCode.h
3 | // SGQRCodeExample
4 | //
5 | // Created by kingsic on 2021/7/5.
6 | // Copyright © 2021 kingsic. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | NS_ASSUME_NONNULL_BEGIN
12 |
13 | @interface SGGenerateQRCode : NSObject
14 | /// 生成二维码
15 | + (UIImage *)generateQRCodeWithData:(NSString *)data size:(CGFloat)size;
16 |
17 | /// 生成二维码(自定义颜色)
18 | ///
19 | /// @param data 二维码数据
20 | /// @param size 二维码大小
21 | /// @param color 二维码颜色
22 | /// @param backgroundColor 二维码背景颜色
23 | + (UIImage *)generateQRCodeWithData:(NSString *)data size:(CGFloat)size color:(UIColor *)color backgroundColor:(UIColor *)backgroundColor;
24 |
25 | /// 生成带 logo 的二维码(推荐使用)
26 | ///
27 | /// @param data 二维码数据
28 | /// @param size 二维码大小
29 | /// @param logoImage logo
30 | /// @param ratio logo 相对二维码的比例(取值范围 0.0 ~ 0.5f)
31 | + (UIImage *)generateQRCodeWithData:(NSString *)data size:(CGFloat)size logoImage:(UIImage *)logoImage ratio:(CGFloat)ratio;
32 |
33 | /// 生成带 logo 的二维码(拓展)
34 | ///
35 | /// @param data 二维码数据
36 | /// @param size 二维码大小
37 | /// @param logoImage logo
38 | /// @param ratio logo 相对二维码的比例(取值范围 0.0 ~ 0.5f)
39 | /// @param logoImageCornerRadius logo 外边框圆角(取值范围 0.0 ~ 10.0f)
40 | /// @param logoImageBorderWidth logo 外边框宽度(取值范围 0.0 ~ 10.0f)
41 | /// @param logoImageBorderColor logo 外边框颜色
42 | + (UIImage *)generateQRCodeWithData:(NSString *)data size:(CGFloat)size logoImage:(UIImage *)logoImage ratio:(CGFloat)ratio logoImageCornerRadius:(CGFloat)logoImageCornerRadius logoImageBorderWidth:(CGFloat)logoImageBorderWidth logoImageBorderColor:(UIColor *)logoImageBorderColor;
43 |
44 | @end
45 |
46 | NS_ASSUME_NONNULL_END
47 |
--------------------------------------------------------------------------------
/SGQRCode/QRCode/SGGenerateQRCode.m:
--------------------------------------------------------------------------------
1 | //
2 | // SGGenerateQRCode.m
3 | // SGQRCodeExample
4 | //
5 | // Created by kingsic on 2021/7/5.
6 | // Copyright © 2021 kingsic. All rights reserved.
7 | //
8 |
9 | #import "SGGenerateQRCode.h"
10 |
11 | @implementation SGGenerateQRCode
12 |
13 | + (UIImage *)generateQRCodeWithData:(NSString *)data size:(CGFloat)size {
14 | return [self generateQRCodeWithData:data size:size color:[UIColor blackColor] backgroundColor:[UIColor whiteColor]];
15 | }
16 |
17 | + (UIImage *)generateQRCodeWithData:(NSString *)data size:(CGFloat)size color:(UIColor *)color backgroundColor:(UIColor *)backgroundColor {
18 | NSData *string_data = [data dataUsingEncoding:NSUTF8StringEncoding];
19 | // 1、二维码滤镜
20 | CIFilter *fileter = [CIFilter filterWithName:@"CIQRCodeGenerator"];
21 | [fileter setValue:string_data forKey:@"inputMessage"];
22 | [fileter setValue:@"H" forKey:@"inputCorrectionLevel"];
23 | CIImage *ciImage = fileter.outputImage;
24 | // 2、颜色滤镜
25 | CIFilter *color_filter = [CIFilter filterWithName:@"CIFalseColor"];
26 | [color_filter setValue:ciImage forKey:@"inputImage"];
27 | [color_filter setValue:[CIColor colorWithCGColor:color.CGColor] forKey:@"inputColor0"];
28 | [color_filter setValue:[CIColor colorWithCGColor:backgroundColor.CGColor] forKey:@"inputColor1"];
29 | // 3、生成处理
30 | CIImage *outImage = color_filter.outputImage;
31 | CGFloat scale = size / outImage.extent.size.width;
32 | outImage = [outImage imageByApplyingTransform:CGAffineTransformMakeScale(scale, scale)];
33 | return [UIImage imageWithCIImage:outImage];
34 | }
35 |
36 | + (UIImage *)generateQRCodeWithData:(NSString *)data size:(CGFloat)size logoImage:(UIImage *)logoImage ratio:(CGFloat)ratio {
37 | return [self generateQRCodeWithData:data size:size logoImage:logoImage ratio:ratio logoImageCornerRadius:5 logoImageBorderWidth:5 logoImageBorderColor:[UIColor whiteColor]];
38 | }
39 |
40 | + (UIImage *)generateQRCodeWithData:(NSString *)data size:(CGFloat)size logoImage:(UIImage *)logoImage ratio:(CGFloat)ratio logoImageCornerRadius:(CGFloat)logoImageCornerRadius logoImageBorderWidth:(CGFloat)logoImageBorderWidth logoImageBorderColor:(UIColor *)logoImageBorderColor {
41 | UIImage *image = [self generateQRCodeWithData:data size:size color:[UIColor blackColor] backgroundColor:[UIColor whiteColor]];
42 | if (logoImage == nil) return image;
43 | if (ratio < 0.0 || ratio > 0.5) {
44 | ratio = 0.25;
45 | }
46 | CGFloat logoImageW = ratio * size;
47 | CGFloat logoImageH = logoImageW;
48 | CGFloat logoImageX = 0.5 * (image.size.width - logoImageW);
49 | CGFloat logoImageY = 0.5 * (image.size.height - logoImageH);
50 | CGRect logoImageRect = CGRectMake(logoImageX, logoImageY, logoImageW, logoImageH);
51 | // 绘制logo
52 | UIGraphicsBeginImageContextWithOptions(image.size, false, [UIScreen mainScreen].scale);
53 | [image drawInRect:CGRectMake(0, 0, image.size.width, image.size.height)];
54 | if (logoImageCornerRadius < 0.0 || logoImageCornerRadius > 10) {
55 | logoImageCornerRadius = 5;
56 | }
57 | UIBezierPath *path = [UIBezierPath bezierPathWithRoundedRect:logoImageRect cornerRadius:logoImageCornerRadius];
58 | if (logoImageBorderWidth < 0.0 || logoImageBorderWidth > 10) {
59 | logoImageBorderWidth = 5;
60 | }
61 | path.lineWidth = logoImageBorderWidth;
62 | [logoImageBorderColor setStroke];
63 | [path stroke];
64 | [path addClip];
65 | [logoImage drawInRect:logoImageRect];
66 | UIImage *QRCodeImage = UIGraphicsGetImageFromCurrentImageContext();
67 | UIGraphicsEndImageContext();
68 | return QRCodeImage;
69 | }
70 |
71 | @end
72 |
--------------------------------------------------------------------------------
/SGQRCode/QRCode/SGScanCode.h:
--------------------------------------------------------------------------------
1 | //
2 | // SGScanCode.h
3 | // SGQRCodeExample
4 | //
5 | // Created by kingsic on 2016/8/16.
6 | // Copyright © 2016年 kingsic. All rights reserved.
7 | //
8 |
9 | #import
10 | #import "SGScanCodeDelegate.h"
11 |
12 | @interface SGScanCode : NSObject
13 | /// 类方法创建
14 | + (instancetype)scanCode;
15 |
16 | /// 预览视图,必须设置(传外界控制器视图)
17 | @property (nonatomic, strong) UIView *preview;
18 |
19 | /// 扫描区域,以屏幕右上角为坐标原点,取值范围:0~1,默认为整个屏幕
20 | @property (nonatomic, assign) CGRect rectOfInterest;
21 |
22 | /// 扫描二维码数据代理
23 | @property (nonatomic, weak) id delegate;
24 |
25 | /// 采样缓冲区代理
26 | @property (nonatomic, weak) id sampleBufferDelegate;
27 |
28 |
29 | /// 读取图片中的二维码
30 | ///
31 | /// @param image 图片
32 | /// @param completion 回调方法,读取成功时,回调参数 result 等于二维码数据,否则等于 nil
33 | - (void)readQRCode:(UIImage *)image completion:(void (^)(NSString *result))completion;
34 |
35 | /// 设置视频缩放因子(捕获内容)
36 | - (void)setVideoZoomFactor:(CGFloat)factor;
37 |
38 | /// 检测后置摄像头是否可用
39 | - (BOOL)checkCameraDeviceRearAvailable;
40 |
41 | /// 开启扫描
42 | - (void)startRunning;
43 | /// 停止扫描
44 | - (void)stopRunning;
45 |
46 | /// 播放音效
47 | - (void)playSoundEffect:(NSString *)name;
48 |
49 | @end
50 |
--------------------------------------------------------------------------------
/SGQRCode/QRCode/SGScanCode.m:
--------------------------------------------------------------------------------
1 | //
2 | // SGScanCode.m
3 | // SGQRCodeExample
4 | //
5 | // Created by kingsic on 2016/8/16.
6 | // Copyright © 2016年 kingsic. All rights reserved.
7 | //
8 |
9 | #import "SGScanCode.h"
10 | #import
11 | #import "SGSoundEffect.h"
12 | #import "SGQRCodeLog.h"
13 |
14 | @interface SGScanCode ()
15 | {
16 | SGSoundEffect *soundEffect;
17 | }
18 | @property (nonatomic, strong) AVCaptureDevice *device;
19 | @property (nonatomic, strong) AVCaptureDeviceInput *deviceInput;
20 | @property (nonatomic, strong) AVCaptureMetadataOutput *metadataOutput;
21 | @property (nonatomic, strong) AVCaptureVideoDataOutput *videoDataOutput;
22 | @property (nonatomic, strong) AVCaptureSession *session;
23 | @property (nonatomic, strong) NSArray *metadataObjectTypes;
24 | @property (nonatomic, strong) AVCaptureVideoPreviewLayer *videoPreviewLayer;
25 | @property (nonatomic, strong) dispatch_queue_t captureQueue;
26 | @end
27 |
28 | @implementation SGScanCode
29 |
30 | - (void)dealloc {
31 | if ([SGQRCodeLog sharedQRCodeLog].log) {
32 | NSLog(@"SGScanCode - - dealloc");
33 | }
34 | }
35 |
36 | + (instancetype)scanCode {
37 | return [[self alloc] init];
38 | }
39 |
40 | - (instancetype)init {
41 | if ([super init]) {
42 | self.captureQueue = dispatch_queue_create("com.SGQRCode.captureQueue", DISPATCH_QUEUE_CONCURRENT);
43 |
44 | /// 将设备输入对象添加到会话对象中
45 | if ([self.session canAddInput:self.deviceInput]) {
46 | [self.session addInput:self.deviceInput];
47 | }
48 |
49 | }
50 | return self;
51 | }
52 |
53 |
54 | #pragma mark - - .h公开的属性
55 | - (void)setPreview:(UIView *)preview {
56 | _preview = preview;
57 | [preview.layer insertSublayer:self.videoPreviewLayer atIndex:0];
58 | }
59 |
60 | - (void)setDelegate:(id)delegate {
61 | _delegate = delegate;
62 |
63 | /// 将元数据输出对象添加到会话对象中
64 | if ([_session canAddOutput:self.metadataOutput]) {
65 | [_session addOutput:self.metadataOutput];
66 | }
67 |
68 | /// 元数据输出对象的二维码识数据别类型
69 | _metadataOutput.metadataObjectTypes = self.metadataObjectTypes;
70 | }
71 |
72 | - (void)setSampleBufferDelegate:(id)sampleBufferDelegate {
73 | _sampleBufferDelegate = sampleBufferDelegate;
74 |
75 | /// 添加捕获输出流到会话对象;构成识了别光线强弱
76 | if ([_session canAddOutput:self.videoDataOutput]) {
77 | [_session addOutput:self.videoDataOutput];
78 | }
79 | }
80 |
81 | - (void)setRectOfInterest:(CGRect)rectOfInterest {
82 | _rectOfInterest = rectOfInterest;
83 | _metadataOutput.rectOfInterest = rectOfInterest;
84 | }
85 |
86 |
87 | #pragma mark - - .h公开的方法
88 | - (void)readQRCode:(UIImage *)image completion:(void (^)(NSString *result))completion {
89 | CIDetector *detector = [CIDetector detectorOfType:CIDetectorTypeQRCode context:nil options:@{CIDetectorAccuracy: CIDetectorAccuracyHigh}];
90 | // 获取识别结果
91 | NSArray *features = [detector featuresInImage:[CIImage imageWithCGImage:image.CGImage]];
92 |
93 | NSString *tempMessageString = nil;
94 | if (features.count > 0) {
95 | CIQRCodeFeature *feature = features[0];
96 | tempMessageString = feature.messageString;
97 | }
98 |
99 | if (completion) {
100 | completion(tempMessageString);
101 | }
102 |
103 | if ([SGQRCodeLog sharedQRCodeLog].log) {
104 | NSLog(@"图片中的二维码数据:%@", tempMessageString);
105 | }
106 | }
107 |
108 | - (void)setVideoZoomFactor:(CGFloat)factor {
109 | if (factor > self.device.maxAvailableVideoZoomFactor) {
110 | factor = self.device.maxAvailableVideoZoomFactor;
111 | } else if (factor < 1) {
112 | factor = 1;
113 | }
114 | // 设置焦距大小
115 | if ([self.device lockForConfiguration:nil]) {
116 | [self.device rampToVideoZoomFactor:factor withRate:10];
117 | [self.device unlockForConfiguration];
118 | }
119 | }
120 |
121 | - (BOOL)checkCameraDeviceRearAvailable {
122 | BOOL isRearCamera = [UIImagePickerController isCameraDeviceAvailable:UIImagePickerControllerCameraDeviceRear];
123 | return isRearCamera;
124 | }
125 |
126 | - (void)startRunning {
127 | if (![self.session isRunning]) {
128 | [self.session startRunning];
129 | }
130 | }
131 |
132 | - (void)stopRunning {
133 | if ([self.session isRunning]) {
134 | [self.session stopRunning];
135 | }
136 | }
137 |
138 | - (void)playSoundEffect:(NSString *)name {
139 | /// 静态库 path 的获取
140 | NSString *path = [[NSBundle mainBundle] pathForResource:name ofType:nil];
141 | if (!path) {
142 | /// 动态库 path 的获取
143 | path = [[NSBundle bundleForClass:[self class]] pathForResource:name ofType:nil];
144 | }
145 |
146 | soundEffect = [SGSoundEffect soundEffectWithFilepath:path];
147 | [soundEffect play];
148 | }
149 |
150 |
151 | #pragma mark - - 内部属性
152 | - (AVCaptureSession *)session {
153 | if (!_session) {
154 | _session = [[AVCaptureSession alloc] init];
155 | _session.sessionPreset = [self sessionPreset];
156 | }
157 | return _session;
158 | }
159 |
160 | - (AVCaptureDevice *)device {
161 | if (!_device) {
162 | _device = [AVCaptureDevice defaultDeviceWithMediaType:AVMediaTypeVideo];
163 | }
164 | return _device;
165 | }
166 |
167 | - (AVCaptureDeviceInput *)deviceInput {
168 | if (!_deviceInput) {
169 | _deviceInput = [AVCaptureDeviceInput deviceInputWithDevice:self.device error:nil];
170 | }
171 | return _deviceInput;
172 | }
173 |
174 | - (AVCaptureMetadataOutput *)metadataOutput {
175 | if (!_metadataOutput) {
176 | _metadataOutput = [[AVCaptureMetadataOutput alloc] init];
177 | [_metadataOutput setMetadataObjectsDelegate:self queue:self.captureQueue];
178 | }
179 | return _metadataOutput;
180 | }
181 |
182 | - (AVCaptureVideoDataOutput *)videoDataOutput {
183 | if (!_videoDataOutput) {
184 | _videoDataOutput = [[AVCaptureVideoDataOutput alloc] init];
185 | [_videoDataOutput setSampleBufferDelegate:self queue:self.captureQueue];
186 | }
187 | return _videoDataOutput;
188 | }
189 |
190 | - (AVCaptureVideoPreviewLayer *)videoPreviewLayer {
191 | if (!_videoPreviewLayer) {
192 | _videoPreviewLayer = [AVCaptureVideoPreviewLayer layerWithSession:_session];
193 | _videoPreviewLayer.videoGravity = AVLayerVideoGravityResizeAspectFill;
194 | _videoPreviewLayer.frame = self.preview.frame;
195 | }
196 | return _videoPreviewLayer;
197 | }
198 |
199 | - (NSArray *)metadataObjectTypes {
200 | if (!_metadataObjectTypes) {
201 | _metadataObjectTypes = @[
202 | AVMetadataObjectTypeUPCECode,
203 | AVMetadataObjectTypeCode39Code,
204 | AVMetadataObjectTypeCode39Mod43Code,
205 | AVMetadataObjectTypeEAN13Code,
206 | AVMetadataObjectTypeEAN8Code,
207 | AVMetadataObjectTypeCode93Code,
208 | AVMetadataObjectTypeCode128Code,
209 | AVMetadataObjectTypePDF417Code,
210 | AVMetadataObjectTypeQRCode,
211 | AVMetadataObjectTypeAztecCode,
212 | AVMetadataObjectTypeInterleaved2of5Code,
213 | AVMetadataObjectTypeITF14Code,
214 | AVMetadataObjectTypeDataMatrixCode,
215 | ];
216 | }
217 | return _metadataObjectTypes;
218 | }
219 |
220 | - (NSString *)sessionPreset {
221 | if ([self.device supportsAVCaptureSessionPreset:AVCaptureSessionPreset3840x2160]) {
222 | return AVCaptureSessionPreset3840x2160;
223 | }
224 | if ([self.device supportsAVCaptureSessionPreset:AVCaptureSessionPreset1920x1080]) {
225 | return AVCaptureSessionPreset1920x1080;
226 | }
227 | if ([self.device supportsAVCaptureSessionPreset:AVCaptureSessionPreset1280x720]) {
228 | return AVCaptureSessionPreset1280x720;
229 | }
230 | if ([self.device supportsAVCaptureSessionPreset:AVCaptureSessionPreset640x480]) {
231 | return AVCaptureSessionPreset640x480;
232 | }
233 | if ([self.device supportsAVCaptureSessionPreset:AVCaptureSessionPreset352x288]) {
234 | return AVCaptureSessionPreset352x288;
235 | }
236 | if ([self.device supportsAVCaptureSessionPreset:AVCaptureSessionPresetHigh]) {
237 | return AVCaptureSessionPresetHigh;
238 | }
239 | if ([self.device supportsAVCaptureSessionPreset:AVCaptureSessionPresetMedium]) {
240 | return AVCaptureSessionPresetMedium;
241 | }
242 |
243 | return AVCaptureSessionPresetLow;
244 | }
245 |
246 | #pragma mark - - AVCaptureMetadataOutputObjectsDelegate 的方法
247 | - (void)captureOutput:(AVCaptureOutput *)captureOutput didOutputMetadataObjects:(NSArray *)metadataObjects fromConnection:(AVCaptureConnection *)connection {
248 | if (metadataObjects != nil && metadataObjects.count > 0) {
249 | AVMetadataMachineReadableCodeObject *obj = metadataObjects[0];
250 | NSString *resultString = obj.stringValue;
251 |
252 | dispatch_async(dispatch_get_main_queue(), ^{
253 | if (self.delegate && [self.delegate respondsToSelector:@selector(scanCode:result:)]) {
254 | [self.delegate scanCode:self result:resultString];
255 | }
256 | });
257 |
258 | if ([SGQRCodeLog sharedQRCodeLog].log) {
259 | NSLog(@"扫描的二维码数据:%@", obj);
260 | }
261 | }
262 | }
263 |
264 | #pragma mark - - AVCaptureVideoDataOutputSampleBufferDelegate 的方法
265 | - (void)captureOutput:(AVCaptureOutput *)captureOutput didOutputSampleBuffer:(CMSampleBufferRef)sampleBuffer fromConnection:(AVCaptureConnection *)connection {
266 | CFDictionaryRef metadataDict = CMCopyDictionaryOfAttachments(NULL, sampleBuffer, kCMAttachmentMode_ShouldPropagate);
267 | NSDictionary *metadata = [[NSMutableDictionary alloc] initWithDictionary:(__bridge NSDictionary*)metadataDict];
268 | CFRelease(metadataDict);
269 | NSDictionary *exifMetadata = [[metadata objectForKey:(NSString *)kCGImagePropertyExifDictionary] mutableCopy];
270 | CGFloat brightnessValue = [[exifMetadata objectForKey:(NSString *)kCGImagePropertyExifBrightnessValue] floatValue];
271 |
272 | dispatch_async(dispatch_get_main_queue(), ^{
273 | if (self.sampleBufferDelegate && [self.sampleBufferDelegate respondsToSelector:@selector(scanCode:brightness:)]) {
274 | [self.sampleBufferDelegate scanCode:self brightness:brightnessValue];
275 | }
276 | });
277 | }
278 |
279 |
280 | @end
281 |
--------------------------------------------------------------------------------
/SGQRCode/QRCode/SGScanCodeDelegate.h:
--------------------------------------------------------------------------------
1 | //
2 | // SGScanCodeDelegate.h
3 | // SGQRCodeExample
4 | //
5 | // Created by kingsic on 2022/7/8.
6 | // Copyright © 2022 kingsic. All rights reserved.
7 | //
8 |
9 | #import
10 | @class SGScanCode;
11 |
12 | @protocol SGScanCodeDelegate
13 | /// 扫描二维码结果函数
14 | ///
15 | /// @param scanCode SGScanCode 对象
16 | /// @param result 扫描二维码数据
17 | - (void)scanCode:(SGScanCode *)scanCode result:(NSString *)result;
18 |
19 | @end
20 |
21 |
22 | @protocol SGScanCodeSampleBufferDelegate
23 | /// 扫描时捕获外界光线强弱函数
24 | ///
25 | /// @param scanCode SGScanCode 对象
26 | /// @param brightness 光线强弱值
27 | - (void)scanCode:(SGScanCode *)scanCode brightness:(CGFloat)brightness;
28 |
29 | @end
30 |
31 |
--------------------------------------------------------------------------------
/SGQRCode/SGQRCode.bundle/Root.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | StringsTable
6 | Root
7 | PreferenceSpecifiers
8 |
9 |
10 | Type
11 | PSGroupSpecifier
12 | Title
13 | Group
14 |
15 |
16 | Type
17 | PSTextFieldSpecifier
18 | Title
19 | Name
20 | Key
21 | name_preference
22 | DefaultValue
23 |
24 | IsSecure
25 |
26 | KeyboardType
27 | Alphabet
28 | AutocapitalizationType
29 | None
30 | AutocorrectionType
31 | No
32 |
33 |
34 | Type
35 | PSToggleSwitchSpecifier
36 | Title
37 | Enabled
38 | Key
39 | enabled_preference
40 | DefaultValue
41 |
42 |
43 |
44 | Type
45 | PSSliderSpecifier
46 | Key
47 | slider_preference
48 | DefaultValue
49 | 0.5
50 | MinimumValue
51 | 0
52 | MaximumValue
53 | 1
54 | MinimumValueImage
55 |
56 | MaximumValueImage
57 |
58 |
59 |
60 |
61 |
62 |
--------------------------------------------------------------------------------
/SGQRCode/SGQRCode.bundle/en.lproj/Root.strings:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kingsic/SGQRCode/41f0640ba8b1e29576121acab72635a7c9c52d17/SGQRCode/SGQRCode.bundle/en.lproj/Root.strings
--------------------------------------------------------------------------------
/SGQRCode/SGQRCode.bundle/scan_end_sound.caf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kingsic/SGQRCode/41f0640ba8b1e29576121acab72635a7c9c52d17/SGQRCode/SGQRCode.bundle/scan_end_sound.caf
--------------------------------------------------------------------------------
/SGQRCode/SGQRCode.bundle/scan_scanline@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kingsic/SGQRCode/41f0640ba8b1e29576121acab72635a7c9c52d17/SGQRCode/SGQRCode.bundle/scan_scanline@2x.png
--------------------------------------------------------------------------------
/SGQRCode/SGQRCode.bundle/scan_scanline@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kingsic/SGQRCode/41f0640ba8b1e29576121acab72635a7c9c52d17/SGQRCode/SGQRCode.bundle/scan_scanline@3x.png
--------------------------------------------------------------------------------
/SGQRCode/SGQRCode.bundle/scan_scanline_qq.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kingsic/SGQRCode/41f0640ba8b1e29576121acab72635a7c9c52d17/SGQRCode/SGQRCode.bundle/scan_scanline_qq.png
--------------------------------------------------------------------------------
/SGQRCode/SGQRCode.bundle/scan_scanline_wb@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kingsic/SGQRCode/41f0640ba8b1e29576121acab72635a7c9c52d17/SGQRCode/SGQRCode.bundle/scan_scanline_wb@2x.png
--------------------------------------------------------------------------------
/SGQRCode/SGQRCode.bundle/scan_scanline_wb@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kingsic/SGQRCode/41f0640ba8b1e29576121acab72635a7c9c52d17/SGQRCode/SGQRCode.bundle/scan_scanline_wb@3x.png
--------------------------------------------------------------------------------
/SGQRCode/SGQRCode.bundle/scan_scanline_wc.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kingsic/SGQRCode/41f0640ba8b1e29576121acab72635a7c9c52d17/SGQRCode/SGQRCode.bundle/scan_scanline_wc.png
--------------------------------------------------------------------------------
/SGQRCode/SGQRCode.h:
--------------------------------------------------------------------------------
1 | //
2 | // SGQRCode.h
3 | // Version 4.1.0
4 | // https://github.com/kingsic/SGQRCode
5 | //
6 | // Created by kingsic on 2016/8/16.
7 | // Copyright © 2016年 kingsic. All rights reserved.
8 | //
9 |
10 | #import "SGQRCodeLog.h"
11 | #import "SGGenerateQRCode.h"
12 | #import "SGScanCode.h"
13 | #import "SGScanCodeDelegate.h"
14 | #import "SGScanView.h"
15 | #import "SGScanViewConfigure.h"
16 | #import "SGPermission.h"
17 | #import "SGSoundEffect.h"
18 | #import "SGTorch.h"
19 | #import "SGWeakProxy.h"
20 |
--------------------------------------------------------------------------------
/SGQRCode/SGQRCodeLog.h:
--------------------------------------------------------------------------------
1 | //
2 | // SGQRCodeLog.h
3 | // SGQRCodeExample
4 | //
5 | // Created by kingsic on 2022/7/15.
6 | // Copyright © 2022 kingsic. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | NS_ASSUME_NONNULL_BEGIN
12 |
13 | @interface SGQRCodeLog : NSObject
14 | /// 单例创建 SGQRCodeLog
15 | + (instancetype)sharedQRCodeLog;
16 |
17 | /// 是否需要打印日志信息,默认为:NO
18 | ///
19 | /// SGScanCode 和 SGScanView 的 dealloc 方法打印,扫描和读取图片中的二维码信息打印
20 | @property (nonatomic, assign) BOOL log;
21 |
22 | @end
23 |
24 | NS_ASSUME_NONNULL_END
25 |
--------------------------------------------------------------------------------
/SGQRCode/SGQRCodeLog.m:
--------------------------------------------------------------------------------
1 | //
2 | // SGQRCodeLog.m
3 | // SGQRCodeExample
4 | //
5 | // Created by kingsic on 2022/7/15.
6 | // Copyright © 2022 kingsic. All rights reserved.
7 | //
8 |
9 | #import "SGQRCodeLog.h"
10 |
11 | static SGQRCodeLog *singleton = nil;
12 |
13 | @implementation SGQRCodeLog
14 |
15 | + (instancetype)sharedQRCodeLog {
16 | static dispatch_once_t onceToken;
17 | dispatch_once(&onceToken, ^{
18 | if (singleton == nil) {
19 | singleton = [[super allocWithZone:NULL] init];
20 | }
21 | });
22 | return singleton;
23 | }
24 |
25 | + (instancetype)allocWithZone:(struct _NSZone *)zone {
26 | return [[self class] sharedQRCodeLog];
27 | }
28 |
29 | - (id)copyWithZone:(NSZone *)zone {
30 | return [[self class] sharedQRCodeLog];
31 | }
32 |
33 | - (id)mutableCopyWithZone:(NSZone *)zone {
34 | return [[self class] sharedQRCodeLog];
35 | }
36 |
37 | @end
38 |
--------------------------------------------------------------------------------
/SGQRCode/ScanView/SGScanView.h:
--------------------------------------------------------------------------------
1 | //
2 | // SGScanView.h
3 | // SGQRCodeExample
4 | //
5 | // Created by kingsic on 2017/8/23.
6 | // Copyright © 2017年 kingsic All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @class SGScanViewConfigure;
12 |
13 | typedef void(^SGScanViewDoubleTapBlock)(BOOL selected);
14 |
15 | @interface SGScanView : UIView
16 | /// 对象方法创建 SGScanView
17 | ///
18 | /// @param frame SGScanView 的 frame
19 | /// @param configure SGScanView 的配置类 SGScanViewConfigure
20 | - (instancetype)initWithFrame:(CGRect)frame configure:(SGScanViewConfigure *)configure;
21 |
22 | /// 类方法创建 SGScanView
23 | ///
24 | /// @param frame SGScanView 的 frame
25 | /// @param configure SGScanView 的配置类 SGScanViewConfigure
26 | + (instancetype)scanViewWithFrame:(CGRect)frame configure:(SGScanViewConfigure *)configure;
27 |
28 | /// 辅助扫描边框区域的frame
29 | ///
30 | /// 默认x为:0.5 * (self.frame.size.width - w)
31 | /// 默认y为:0.5 * (self.frame.size.height - w)
32 | /// 默认width和height为:0.7 * self.frame.size.width
33 | @property (nonatomic, assign) CGRect borderFrame;
34 |
35 | /// 扫描区域的frame
36 | @property (nonatomic, assign) CGRect scanFrame;
37 |
38 | /// 双击回调方法
39 | @property (nonatomic, copy) SGScanViewDoubleTapBlock doubleTapBlock;
40 |
41 |
42 | /// 开始扫描
43 | - (void)startScanning;
44 |
45 | /// 停止扫描
46 | - (void)stopScanning;
47 |
48 | @end
49 |
--------------------------------------------------------------------------------
/SGQRCode/ScanView/SGScanView.m:
--------------------------------------------------------------------------------
1 | //
2 | // SGScanView.m
3 | // SGQRCodeExample
4 | //
5 | // Created by kingsic on 2017/8/23.
6 | // Copyright © 2017年 kingsic All rights reserved.
7 | //
8 |
9 | #import "SGScanView.h"
10 | #import "SGScanViewConfigure.h"
11 | #import "SGWeakProxy.h"
12 | #import "SGQRCodeLog.h"
13 |
14 | @interface SGScanView ()
15 | @property (nonatomic, strong) SGScanViewConfigure *configure;
16 | @property (nonatomic, strong) UIView *contentView;
17 | @property (nonatomic, strong) UIImageView *scanlineImgView;
18 | @property (nonatomic, strong) CADisplayLink *link;
19 | @property (nonatomic, assign) BOOL isTop;
20 | @property (nonatomic, assign) BOOL isSelected;
21 | @end
22 |
23 | @implementation SGScanView
24 |
25 | - (void)dealloc {
26 | if ([SGQRCodeLog sharedQRCodeLog].log) {
27 | NSLog(@"SGScanView - - dealloc");
28 | }
29 | }
30 |
31 | - (instancetype)initWithFrame:(CGRect)frame configure:(SGScanViewConfigure *)configure {
32 | if (self = [super initWithFrame:frame]) {
33 | self.configure = configure;
34 |
35 | self.backgroundColor = [UIColor clearColor];
36 |
37 | [self initialization];
38 | [self addSubview:self.contentView];
39 |
40 | UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tap_action)];
41 | tap.numberOfTapsRequired = 2;
42 | [self addGestureRecognizer:tap];
43 | }
44 | return self;
45 | }
46 |
47 | + (instancetype)scanViewWithFrame:(CGRect)frame configure:(SGScanViewConfigure *)configure {
48 | return [[SGScanView alloc] initWithFrame:frame configure:configure];
49 | }
50 |
51 | - (void)initialization {
52 | CGFloat w = 0.7 * self.frame.size.width;
53 | CGFloat h = w;
54 | CGFloat x = 0.5 * (self.frame.size.width - w);
55 | CGFloat y = 0.5 * (self.frame.size.height - h);
56 | _borderFrame = CGRectMake(x, y, w, h);
57 | _scanFrame = CGRectMake(x, y, w, h);
58 |
59 | self.isTop = YES;
60 | }
61 |
62 | - (UIView *)contentView {
63 | if (!_contentView) {
64 | CGFloat x = _scanFrame.origin.x;
65 | CGFloat y = _scanFrame.origin.y;
66 | CGFloat w = _scanFrame.size.width;
67 | CGFloat h = _scanFrame.size.height;
68 | _contentView = [[UIView alloc] initWithFrame:CGRectMake(x, y, w, h)];
69 | _contentView.backgroundColor = [UIColor clearColor];
70 | _contentView.clipsToBounds = YES;
71 | }
72 | return _contentView;
73 | }
74 |
75 | - (UIImageView *)scanlineImgView {
76 | if (!_scanlineImgView) {
77 | _scanlineImgView = [[UIImageView alloc] init];
78 |
79 | /// 静态库 url 的获取
80 | NSURL *url = [[NSBundle mainBundle] URLForResource:@"SGQRCode" withExtension:@"bundle"];
81 | if (!url) {
82 | /// 动态库 url 的获取
83 | url = [[NSBundle bundleForClass:[self class]] URLForResource:@"SGQRCode" withExtension:@"bundle"];
84 | }
85 | NSBundle *bundle = [NSBundle bundleWithURL:url];
86 |
87 | UIImage *image = [UIImage imageNamed:self.configure.scanline inBundle:bundle compatibleWithTraitCollection:nil];
88 | if (!image) {
89 | image = [UIImage imageNamed:self.configure.scanline];
90 | }
91 | _scanlineImgView.image = image;
92 |
93 | if (image) {
94 | [self updateScanLineFrame];
95 | }
96 | }
97 | return _scanlineImgView;
98 | }
99 |
100 | - (void)tap_action {
101 | if (self.isSelected) {
102 | self.isSelected = NO;
103 | } else {
104 | self.isSelected = YES;
105 | }
106 |
107 | if (self.doubleTapBlock) {
108 | self.doubleTapBlock(self.isSelected);
109 | }
110 | }
111 |
112 | - (void)drawRect:(CGRect)rect {
113 | [super drawRect:rect];
114 |
115 | if (self.configure.isShowBorder == NO) {
116 | return;
117 | }
118 |
119 | /// 边框 frame
120 | CGFloat borderW = self.borderFrame.size.width;
121 | CGFloat borderH = self.borderFrame.size.height;
122 | CGFloat borderX = self.borderFrame.origin.x;
123 | CGFloat borderY = self.borderFrame.origin.y;
124 | CGFloat borderLineW = self.configure.borderWidth;
125 |
126 | /// 空白区域设置
127 | [self.configure.color setFill];
128 | UIRectFill(rect);
129 | // 获取上下文,并设置混合模式 -> kCGBlendModeDestinationOut
130 | CGContextRef context = UIGraphicsGetCurrentContext();
131 | CGContextSetBlendMode(context, kCGBlendModeDestinationOut);
132 | // 设置空白区
133 | UIBezierPath *bezierPath = [UIBezierPath bezierPathWithRect:CGRectMake(borderX + 0.5 * borderLineW, borderY + 0.5 *borderLineW, borderW - borderLineW, borderH - borderLineW)];
134 | [bezierPath fill];
135 | // 执行混合模式
136 | CGContextSetBlendMode(context, kCGBlendModeNormal);
137 |
138 |
139 | /// 边框设置
140 | UIBezierPath *borderPath = [UIBezierPath bezierPathWithRect:CGRectMake(borderX, borderY, borderW, borderH)];
141 | borderPath.lineCapStyle = kCGLineCapButt;
142 | borderPath.lineWidth = borderLineW;
143 | [self.configure.borderColor set];
144 | [borderPath stroke];
145 |
146 |
147 | CGFloat cornerLength = self.configure.cornerLength;
148 | CGFloat insideExcess = fabs(0.5 * (self.configure.cornerWidth - borderLineW));
149 | CGFloat outsideExcess = 0.5 * (borderLineW + self.configure.cornerWidth);
150 |
151 | /// 左上角小图标
152 | [self leftTop:borderX borderY:borderY cornerLength:cornerLength insideExcess:insideExcess outsideExcess:outsideExcess];
153 |
154 | /// 左下角小图标
155 | [self leftBottom:borderX borderY:borderY borderH:borderH cornerLength:cornerLength insideExcess:insideExcess outsideExcess:outsideExcess];
156 |
157 | /// 右上角小图标
158 | [self rightTop:borderX borderY:borderY borderW:borderW cornerLength:cornerLength insideExcess:insideExcess outsideExcess:outsideExcess];
159 |
160 | /// 右下角小图标
161 | [self rightBottom:borderX borderY:borderY borderW:borderW borderH:borderH cornerLength:cornerLength insideExcess:insideExcess outsideExcess:outsideExcess];
162 | }
163 |
164 | - (void)leftTop:(CGFloat)borderX borderY:(CGFloat)borderY cornerLength:(CGFloat)cornerLength insideExcess:(CGFloat) insideExcess outsideExcess:(CGFloat)outsideExcess {
165 | UIBezierPath *leftTopPath = [UIBezierPath bezierPath];
166 | leftTopPath.lineWidth = self.configure.cornerWidth;
167 | [self.configure.cornerColor set];
168 |
169 | if (self.configure.cornerLocation == SGCornerLoactionInside) {
170 | [leftTopPath moveToPoint:CGPointMake(borderX + insideExcess, borderY + cornerLength + insideExcess)];
171 | [leftTopPath addLineToPoint:CGPointMake(borderX + insideExcess, borderY + insideExcess)];
172 | [leftTopPath addLineToPoint:CGPointMake(borderX + cornerLength + insideExcess, borderY + insideExcess)];
173 | } else if (self.configure.cornerLocation == SGCornerLoactionOutside) {
174 | [leftTopPath moveToPoint:CGPointMake(borderX - outsideExcess, borderY + cornerLength - outsideExcess)];
175 | [leftTopPath addLineToPoint:CGPointMake(borderX - outsideExcess, borderY - outsideExcess)];
176 | [leftTopPath addLineToPoint:CGPointMake(borderX + cornerLength - outsideExcess, borderY - outsideExcess)];
177 | } else {
178 | [leftTopPath moveToPoint:CGPointMake(borderX, borderY + cornerLength)];
179 | [leftTopPath addLineToPoint:CGPointMake(borderX, borderY)];
180 | [leftTopPath addLineToPoint:CGPointMake(borderX + cornerLength, borderY)];
181 | }
182 |
183 | [leftTopPath stroke];
184 | }
185 |
186 | - (void)rightTop:(CGFloat)borderX borderY:(CGFloat)borderY borderW:(CGFloat)borderW cornerLength:(CGFloat)cornerLength insideExcess:(CGFloat) insideExcess outsideExcess:(CGFloat)outsideExcess {
187 | UIBezierPath *rightTopPath = [UIBezierPath bezierPath];
188 | rightTopPath.lineWidth = self.configure.cornerWidth;
189 | [self.configure.cornerColor set];
190 |
191 | if (self.configure.cornerLocation == SGCornerLoactionInside) {
192 | [rightTopPath moveToPoint:CGPointMake(borderX + borderW - cornerLength - insideExcess, borderY + insideExcess)];
193 | [rightTopPath addLineToPoint:CGPointMake(borderX + borderW - insideExcess, borderY + insideExcess)];
194 | [rightTopPath addLineToPoint:CGPointMake(borderX + borderW - insideExcess, borderY + cornerLength + insideExcess)];
195 | } else if (self.configure.cornerLocation == SGCornerLoactionOutside) {
196 | [rightTopPath moveToPoint:CGPointMake(borderX + borderW - cornerLength + outsideExcess, borderY - outsideExcess)];
197 | [rightTopPath addLineToPoint:CGPointMake(borderX + borderW + outsideExcess, borderY - outsideExcess)];
198 | [rightTopPath addLineToPoint:CGPointMake(borderX + borderW + outsideExcess, borderY + cornerLength - outsideExcess)];
199 | } else {
200 | [rightTopPath moveToPoint:CGPointMake(borderX + borderW - cornerLength, borderY)];
201 | [rightTopPath addLineToPoint:CGPointMake(borderX + borderW, borderY)];
202 | [rightTopPath addLineToPoint:CGPointMake(borderX + borderW, borderY + cornerLength)];
203 | }
204 |
205 | [rightTopPath stroke];
206 | }
207 |
208 | - (void)leftBottom:(CGFloat)borderX borderY:(CGFloat)borderY borderH:(CGFloat)borderH cornerLength:(CGFloat)cornerLength insideExcess:(CGFloat) insideExcess outsideExcess:(CGFloat)outsideExcess {
209 | UIBezierPath *leftBottomPath = [UIBezierPath bezierPath];
210 | leftBottomPath.lineWidth = self.configure.cornerWidth;
211 | [self.configure.cornerColor set];
212 |
213 | if (self.configure.cornerLocation == SGCornerLoactionInside) {
214 | [leftBottomPath moveToPoint:CGPointMake(borderX + cornerLength + insideExcess, borderY + borderH - insideExcess)];
215 | [leftBottomPath addLineToPoint:CGPointMake(borderX + insideExcess, borderY + borderH - insideExcess)];
216 | [leftBottomPath addLineToPoint:CGPointMake(borderX + insideExcess, borderY + borderH - cornerLength - insideExcess)];
217 | } else if (self.configure.cornerLocation == SGCornerLoactionOutside) {
218 | [leftBottomPath moveToPoint:CGPointMake(borderX + cornerLength - outsideExcess, borderY + borderH + outsideExcess)];
219 | [leftBottomPath addLineToPoint:CGPointMake(borderX - outsideExcess, borderY + borderH + outsideExcess)];
220 | [leftBottomPath addLineToPoint:CGPointMake(borderX - outsideExcess, borderY + borderH - cornerLength + outsideExcess)];
221 | } else {
222 | [leftBottomPath moveToPoint:CGPointMake(borderX + cornerLength, borderY + borderH)];
223 | [leftBottomPath addLineToPoint:CGPointMake(borderX, borderY + borderH)];
224 | [leftBottomPath addLineToPoint:CGPointMake(borderX, borderY + borderH - cornerLength)];
225 | }
226 |
227 | [leftBottomPath stroke];
228 | }
229 |
230 | - (void)rightBottom:(CGFloat)borderX borderY:(CGFloat)borderY borderW:(CGFloat)borderW borderH:(CGFloat)borderH cornerLength:(CGFloat)cornerLength insideExcess:(CGFloat) insideExcess outsideExcess:(CGFloat)outsideExcess {
231 | UIBezierPath *rightBottomPath = [UIBezierPath bezierPath];
232 | rightBottomPath.lineWidth = self.configure.cornerWidth;
233 | [self.configure.cornerColor set];
234 |
235 | if (self.configure.cornerLocation == SGCornerLoactionInside) {
236 | [rightBottomPath moveToPoint:CGPointMake(borderX + borderW - insideExcess, borderY + borderH - cornerLength - insideExcess)];
237 | [rightBottomPath addLineToPoint:CGPointMake(borderX + borderW - insideExcess, borderY + borderH - insideExcess)];
238 | [rightBottomPath addLineToPoint:CGPointMake(borderX + borderW - cornerLength - insideExcess, borderY + borderH - insideExcess)];
239 | } else if (self.configure.cornerLocation == SGCornerLoactionOutside) {
240 | [rightBottomPath moveToPoint:CGPointMake(borderX + borderW + outsideExcess, borderY + borderH - cornerLength + outsideExcess)];
241 | [rightBottomPath addLineToPoint:CGPointMake(borderX + borderW + outsideExcess, borderY + borderH + outsideExcess)];
242 | [rightBottomPath addLineToPoint:CGPointMake(borderX + borderW - cornerLength + outsideExcess, borderY + borderH + outsideExcess)];
243 | } else {
244 | [rightBottomPath moveToPoint:CGPointMake(borderX + borderW, borderY + borderH - cornerLength)];
245 | [rightBottomPath addLineToPoint:CGPointMake(borderX + borderW, borderY + borderH)];
246 | [rightBottomPath addLineToPoint:CGPointMake(borderX + borderW - cornerLength, borderY + borderH)];
247 | }
248 |
249 | [rightBottomPath stroke];
250 | }
251 |
252 | - (void)setBorderFrame:(CGRect)borderFrame {
253 | _borderFrame = borderFrame;
254 | }
255 |
256 | - (void)setScanFrame:(CGRect)scanFrame {
257 | _scanFrame = scanFrame;
258 |
259 | self.contentView.frame = scanFrame;
260 |
261 | if (self.scanlineImgView.image) {
262 | [self updateScanLineFrame];
263 | }
264 | }
265 |
266 | - (void)updateScanLineFrame {
267 | CGFloat w = _contentView.frame.size.width;
268 | CGFloat h = (w * self.scanlineImgView.image.size.height) / self.scanlineImgView.image.size.width;
269 | CGFloat x = 0;
270 | CGFloat y = self.configure.isFromTop ? -h : 0;
271 | self.scanlineImgView.frame = CGRectMake(x, y, w, h);
272 | }
273 |
274 | - (void)startScanning {
275 | if (self.scanlineImgView.image == nil) {
276 | return;
277 | }
278 |
279 | [self.contentView addSubview:self.scanlineImgView];
280 |
281 | if (self.link == nil) {
282 | self.link = [CADisplayLink displayLinkWithTarget:[SGWeakProxy weakProxyWithTarget:self] selector:@selector(updateUI)];
283 | [self.link addToRunLoop:[NSRunLoop mainRunLoop] forMode:NSRunLoopCommonModes];
284 | }
285 | }
286 |
287 | - (void)stopScanning {
288 | if (self.scanlineImgView.image == nil) {
289 | return;
290 | }
291 |
292 | // 此代码防止由于外界逻辑,可能会导致多次停止
293 | if (self.link == nil) {
294 | return;
295 | }
296 |
297 | [self.scanlineImgView removeFromSuperview];
298 | self.scanlineImgView = nil;
299 |
300 | [self.link invalidate];
301 | self.link = nil;
302 | }
303 |
304 | - (void)updateUI {
305 | CGRect frame = self.scanlineImgView.frame;
306 | CGFloat contentViewHeight = CGRectGetHeight(self.contentView.frame);
307 |
308 | CGFloat scanlineY = self.scanlineImgView.frame.origin.y + (self.configure.isFromTop ? 0 : self.scanlineImgView.frame.size.height);
309 |
310 | if (self.configure.autoreverses) {
311 | if (self.isTop) {
312 | frame.origin.y += self.configure.scanlineStep;
313 | self.scanlineImgView.frame = frame;
314 |
315 | if (contentViewHeight <= scanlineY) {
316 | self.isTop = NO;
317 | }
318 | } else {
319 | frame.origin.y -= self.configure.scanlineStep;
320 | self.scanlineImgView.frame = frame;
321 |
322 | if (scanlineY <= self.scanlineImgView.frame.size.height) {
323 | self.isTop = YES;
324 | }
325 | }
326 | } else {
327 | if (contentViewHeight <= scanlineY) {
328 | CGFloat scanlineH = self.scanlineImgView.frame.size.height;
329 | frame.origin.y = -scanlineH + (self.configure.isFromTop ? 0 : scanlineH);
330 | self.scanlineImgView.frame = frame;
331 | } else {
332 | frame.origin.y += self.configure.scanlineStep;
333 | self.scanlineImgView.frame = frame;
334 | }
335 | }
336 | }
337 |
338 | @end
339 |
--------------------------------------------------------------------------------
/SGQRCode/ScanView/SGScanViewConfigure.h:
--------------------------------------------------------------------------------
1 | //
2 | // SGScanViewConfigure.h
3 | // SGQRCodeExample
4 | //
5 | // Created by kingsic on 2022/7/9.
6 | // Copyright © 2022 kingsic. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | typedef enum : NSUInteger {
12 | /// 默认与边框线同中心点
13 | SGCornerLoactionDefault,
14 | /// 在边框线内部
15 | SGCornerLoactionInside,
16 | /// 在边框线外部
17 | SGCornerLoactionOutside
18 | } SGCornerLoaction;
19 |
20 | NS_ASSUME_NONNULL_BEGIN
21 |
22 | @interface SGScanViewConfigure : NSObject
23 | /// 类方法创建
24 | + (instancetype)configure;
25 |
26 | /// 扫描线
27 | @property (nonatomic, copy) NSString *scanline;
28 |
29 | /// 扫描线每次移动的步长,默认为:3.5f
30 | @property (nonatomic, assign) CGFloat scanlineStep;
31 |
32 | /// 扫描线是否执行逆动画,默认为:NO
33 | @property (nonatomic, assign) BOOL autoreverses;
34 |
35 | /// 扫描线是否从扫描框顶部开始扫描,默认为:NO
36 | @property (nonatomic, assign) BOOL isFromTop;
37 |
38 | /// SGScanView 背景色,默认为:[[UIColor blackColor] colorWithAlphaComponent:0.5]
39 | @property (nonatomic, strong) UIColor *color;
40 |
41 | /// 是否需要辅助扫描框,默认为:NO
42 | @property (nonatomic, assign) BOOL isShowBorder;
43 |
44 | /// 辅助扫描框的颜色,默认为:[UIColor whiteColor]
45 | @property (nonatomic, strong) UIColor *borderColor;
46 |
47 | /// 辅助扫描框的宽度,默认为:0.2f
48 | @property (nonatomic, assign) CGFloat borderWidth;
49 |
50 | /// 辅助扫描边角位置,默认为:SGCornerLoactionDefault
51 | @property (nonatomic, assign) SGCornerLoaction cornerLocation;
52 |
53 | /// 辅助扫描边角颜色,默认为:[UIColor greenColor]
54 | @property (nonatomic, strong) UIColor *cornerColor;
55 |
56 | /// 辅助扫描边角宽度,默认为:2.0f
57 | @property (nonatomic, assign) CGFloat cornerWidth;
58 |
59 | /// 辅助扫描边角长度,默认为:20.0f
60 | @property (nonatomic, assign) CGFloat cornerLength;
61 |
62 | @end
63 |
64 | NS_ASSUME_NONNULL_END
65 |
--------------------------------------------------------------------------------
/SGQRCode/ScanView/SGScanViewConfigure.m:
--------------------------------------------------------------------------------
1 | //
2 | // SGScanViewConfigure.m
3 | // SGQRCodeExample
4 | //
5 | // Created by kingsic on 2022/7/9.
6 | // Copyright © 2022 kingsic. All rights reserved.
7 | //
8 |
9 | #import "SGScanViewConfigure.h"
10 |
11 | @implementation SGScanViewConfigure
12 |
13 | - (instancetype)init {
14 | if (self = [super init]) {
15 | _isShowBorder = NO;
16 | }
17 | return self;
18 | }
19 |
20 | + (instancetype)configure {
21 | return [[self alloc] init];
22 | }
23 |
24 | - (NSString *)scanline {
25 | if (!_scanline) {
26 | return @"scan_scanline_wc";
27 | }
28 | return _scanline;
29 | }
30 |
31 | - (CGFloat)scanlineStep {
32 | if (!_scanlineStep) {
33 | return 3.5;
34 | }
35 | return _scanlineStep;
36 | }
37 |
38 | - (UIColor *)color {
39 | if (!_color) {
40 | return [[UIColor blackColor] colorWithAlphaComponent:0.5];
41 | }
42 | return _color;
43 | }
44 |
45 | - (UIColor *)borderColor {
46 | if (!_borderColor) {
47 | return [UIColor whiteColor];
48 | }
49 | return _borderColor;
50 | }
51 |
52 | - (CGFloat)borderWidth {
53 | if (!_borderWidth) {
54 | return 0.2;
55 | }
56 | return _borderWidth;
57 | }
58 |
59 | - (SGCornerLoaction)cornerLocation {
60 | if (!_cornerLocation) {
61 | return SGCornerLoactionDefault;
62 | }
63 | return _cornerLocation;
64 | }
65 |
66 | - (UIColor *)cornerColor {
67 | if (!_cornerColor) {
68 | _cornerColor = [UIColor greenColor];
69 | }
70 | return _cornerColor;
71 | }
72 |
73 | - (CGFloat)cornerWidth {
74 | if (!_cornerWidth) {
75 | return 2.0;
76 | }
77 | return _cornerWidth;
78 | }
79 |
80 | - (CGFloat)cornerLength {
81 | if (!_cornerLength) {
82 | return 20.0;
83 | }
84 | return _cornerLength;
85 | }
86 |
87 | @end
88 |
--------------------------------------------------------------------------------
/SGQRCode/SoundEffect/SGSoundEffect.h:
--------------------------------------------------------------------------------
1 | //
2 | // SGSoundEffect.h
3 | // SGQRCodeExample
4 | //
5 | // Created by kingsic on 2022/7/8.
6 | // Copyright © 2022 kingsic. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | NS_ASSUME_NONNULL_BEGIN
12 |
13 | @interface SGSoundEffect : NSObject
14 | /// 对象方法获取音效文件
15 | - (id)initWithFilepath:(NSString *)path;
16 |
17 | /// 类方法获取音效文件
18 | + (id)soundEffectWithFilepath:(NSString *)path;
19 |
20 | /// 开始播放音效
21 | - (void)play;
22 |
23 | @end
24 |
25 | NS_ASSUME_NONNULL_END
26 |
--------------------------------------------------------------------------------
/SGQRCode/SoundEffect/SGSoundEffect.m:
--------------------------------------------------------------------------------
1 | //
2 | // SGSoundEffect.m
3 | // SGQRCodeExample
4 | //
5 | // Created by kingsic on 2022/7/8.
6 | // Copyright © 2022 kingsic. All rights reserved.
7 | //
8 |
9 | #import "SGSoundEffect.h"
10 | #import
11 |
12 | @interface SGSoundEffect ()
13 | {
14 | SystemSoundID _soundID;
15 | }
16 | @end
17 |
18 | @implementation SGSoundEffect
19 |
20 | - (id)initWithFilepath:(NSString *)path {
21 | self = [super init];
22 |
23 | if (self != nil) {
24 |
25 | // 获取声音文件路径
26 | NSURL *aFileURL = [NSURL fileURLWithPath:path isDirectory:NO];
27 |
28 | // 判断声音文件是否存在
29 | if (aFileURL != nil) {
30 | // 定义SystemSoundID
31 | SystemSoundID aSoundID;
32 |
33 | // 允许应用程序指定由系统声音服务器播放的音频文件
34 | /*
35 | 参数1:A CFURLRef for an AudioFile ,一个CFURLRef类型的音频文件
36 | 参数2:Returns a SystemSoundID,返回一个SystemSoundID
37 | */
38 | OSStatus error = AudioServicesCreateSystemSoundID((__bridge CFURLRef)aFileURL, &aSoundID);
39 | // 判断 error 是否等于无错误!
40 | if (error == kAudioServicesNoError) {
41 | // 赋值:
42 | _soundID = aSoundID;
43 | } else {
44 | NSLog(@"Error :loading sound path, %d, %@", (int)error, path);
45 | self = nil;
46 | }
47 | } else {
48 | NSLog(@"URL is nil for path %@", path);
49 | self = nil;
50 | }
51 | }
52 |
53 | return self;
54 | }
55 |
56 | + (id)soundEffectWithFilepath:(NSString *)path {
57 | if (path) {
58 | return [[SGSoundEffect alloc] initWithFilepath:path];
59 | }
60 | return nil;
61 | }
62 |
63 | - (void)play {
64 | AudioServicesPlaySystemSound(_soundID);
65 | }
66 |
67 | - (void)dealloc {
68 | AudioServicesDisposeSystemSoundID(_soundID);
69 | }
70 |
71 | @end
72 |
--------------------------------------------------------------------------------
/SGQRCode/Torch/SGTorch.h:
--------------------------------------------------------------------------------
1 | //
2 | // SGTorch.h
3 | // SGQRCodeExample
4 | //
5 | // Created by kingsic on 2022/7/9.
6 | // Copyright © 2022 kingsic. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | NS_ASSUME_NONNULL_BEGIN
12 |
13 | @interface SGTorch : NSObject
14 | /// 打开手电筒
15 | + (void)turnOnTorch;
16 |
17 | /// 关闭手电筒
18 | + (void)turnOffTorch;
19 |
20 | @end
21 |
22 | NS_ASSUME_NONNULL_END
23 |
--------------------------------------------------------------------------------
/SGQRCode/Torch/SGTorch.m:
--------------------------------------------------------------------------------
1 | //
2 | // SGTorch.m
3 | // SGQRCodeExample
4 | //
5 | // Created by kingsic on 2022/7/9.
6 | // Copyright © 2022 kingsic. All rights reserved.
7 | //
8 |
9 | #import "SGTorch.h"
10 | #import
11 |
12 | @implementation SGTorch
13 |
14 | + (void)turnOnTorch {
15 | AVCaptureDevice *device = [AVCaptureDevice defaultDeviceWithMediaType:AVMediaTypeVideo];
16 | if ([device hasTorch]) {
17 | BOOL locked = [device lockForConfiguration:nil];
18 | if (locked) {
19 | [device setTorchMode:AVCaptureTorchModeOn];
20 | [device unlockForConfiguration];
21 | }
22 | }
23 | }
24 |
25 | + (void)turnOffTorch {
26 | AVCaptureDevice *device = [AVCaptureDevice defaultDeviceWithMediaType:AVMediaTypeVideo];
27 |
28 | if ([device hasTorch]) {
29 | [device lockForConfiguration:nil];
30 | [device setTorchMode:AVCaptureTorchModeOff];
31 | [device unlockForConfiguration];
32 | }
33 | }
34 |
35 | @end
36 |
--------------------------------------------------------------------------------
/SGQRCode/WeakProxy/SGWeakProxy.h:
--------------------------------------------------------------------------------
1 | //
2 | // SGWeakProxy.h
3 | // SGQRCodeExample
4 | //
5 | // Created by kingsic on 2022/7/2.
6 | //
7 |
8 | #import
9 |
10 | NS_ASSUME_NONNULL_BEGIN
11 |
12 | @interface SGWeakProxy : NSProxy
13 | /// 类方法创建 SGWeakProxy
14 | + (instancetype)weakProxyWithTarget:(id)aTarget;
15 |
16 | @end
17 |
18 | NS_ASSUME_NONNULL_END
19 |
--------------------------------------------------------------------------------
/SGQRCode/WeakProxy/SGWeakProxy.m:
--------------------------------------------------------------------------------
1 | //
2 | // SGWeakProxy.m
3 | // SGQRCodeExample
4 | //
5 | // Created by kingsic on 2022/7/2.
6 | //
7 |
8 | #import "SGWeakProxy.h"
9 |
10 | @interface SGWeakProxy ()
11 | @property (nonatomic, weak) id target;
12 | @end
13 |
14 | @implementation SGWeakProxy
15 |
16 | + (instancetype)weakProxyWithTarget:(id)aTarget {
17 | SGWeakProxy *weakProxy = [SGWeakProxy alloc];
18 | weakProxy.target = aTarget;
19 | return weakProxy;
20 | }
21 |
22 |
23 | - (id)forwardingTargetForSelector:(SEL)selector {
24 | return _target;
25 | }
26 |
27 | - (void)forwardInvocation:(NSInvocation *)invocation {
28 | void *nullPointer = NULL;
29 | [invocation setReturnValue:&nullPointer];
30 | }
31 |
32 | - (NSMethodSignature *)methodSignatureForSelector:(SEL)selector {
33 | return [NSObject instanceMethodSignatureForSelector:@selector(init)];
34 | }
35 |
36 | @end
37 |
--------------------------------------------------------------------------------
/SGQRCodeExample.xcodeproj/project.pbxproj:
--------------------------------------------------------------------------------
1 | // !$*UTF8*$!
2 | {
3 | archiveVersion = 1;
4 | classes = {
5 | };
6 | objectVersion = 46;
7 | objects = {
8 |
9 | /* Begin PBXBuildFile section */
10 | 180E360F1F01F33E00A53E7A /* WebViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 180E36081F01F33E00A53E7A /* WebViewController.m */; };
11 | 18479ECF1E80F92500F7F225 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 18479ECE1E80F92500F7F225 /* main.m */; };
12 | 18479ED21E80F92500F7F225 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 18479ED11E80F92500F7F225 /* AppDelegate.m */; };
13 | 18479EDA1E80F92500F7F225 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 18479ED91E80F92500F7F225 /* Assets.xcassets */; };
14 | 18479EDD1E80F92500F7F225 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 18479EDB1E80F92500F7F225 /* LaunchScreen.storyboard */; };
15 | 18479EE81E80F92500F7F225 /* SGQRCodeExampleTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 18479EE71E80F92500F7F225 /* SGQRCodeExampleTests.m */; };
16 | 18479EF31E80F92500F7F225 /* SGQRCodeExampleUITests.m in Sources */ = {isa = PBXBuildFile; fileRef = 18479EF21E80F92500F7F225 /* SGQRCodeExampleUITests.m */; };
17 | 18479F0B1E80F97700F7F225 /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 18479F071E80F97700F7F225 /* ViewController.m */; };
18 | 18479F1A1E80F98F00F7F225 /* SGQRCode.bundle in Resources */ = {isa = PBXBuildFile; fileRef = 18479F101E80F98F00F7F225 /* SGQRCode.bundle */; };
19 | 18479F1F1E80F9CA00F7F225 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 18479F1E1E80F9CA00F7F225 /* Main.storyboard */; };
20 | 8D19272E210DFF88002AE63A /* WBQRCodeVC.m in Sources */ = {isa = PBXBuildFile; fileRef = 8D19272D210DFF88002AE63A /* WBQRCodeVC.m */; };
21 | 8D3DFEFE2662984800E02474 /* SGScanCode.m in Sources */ = {isa = PBXBuildFile; fileRef = 8D3DFEFD2662984800E02474 /* SGScanCode.m */; };
22 | 8D805A6B2880EC1600E91BC4 /* SGQRCodeLog.m in Sources */ = {isa = PBXBuildFile; fileRef = 8D805A6A2880EC1600E91BC4 /* SGQRCodeLog.m */; };
23 | 8D82F1FB28781C5D00B72DE9 /* SGPermission.m in Sources */ = {isa = PBXBuildFile; fileRef = 8D82F1FA28781C5D00B72DE9 /* SGPermission.m */; };
24 | 8D82F1FE28781DEF00B72DE9 /* SGPermissionCamera.m in Sources */ = {isa = PBXBuildFile; fileRef = 8D82F1FD28781DEF00B72DE9 /* SGPermissionCamera.m */; };
25 | 8D82F207287834E200B72DE9 /* SGPermissionPhoto.m in Sources */ = {isa = PBXBuildFile; fileRef = 8D82F206287834E200B72DE9 /* SGPermissionPhoto.m */; };
26 | 8D82F20E28785C0C00B72DE9 /* SGSoundEffect.m in Sources */ = {isa = PBXBuildFile; fileRef = 8D82F20D28785C0C00B72DE9 /* SGSoundEffect.m */; };
27 | 8D82F2142879166000B72DE9 /* SGScanViewConfigure.m in Sources */ = {isa = PBXBuildFile; fileRef = 8D82F2132879166000B72DE9 /* SGScanViewConfigure.m */; };
28 | 8D82F21828794E2500B72DE9 /* SGWeakProxy.m in Sources */ = {isa = PBXBuildFile; fileRef = 8D82F21728794E2500B72DE9 /* SGWeakProxy.m */; };
29 | 8D82F22928798D1F00B72DE9 /* WCQRCodeVC.m in Sources */ = {isa = PBXBuildFile; fileRef = 8D82F22728798D1F00B72DE9 /* WCQRCodeVC.m */; };
30 | 8D82F22C28798FEA00B72DE9 /* WCToolBar.m in Sources */ = {isa = PBXBuildFile; fileRef = 8D82F22B28798FEA00B72DE9 /* WCToolBar.m */; };
31 | 8D82F23A2879A9EA00B72DE9 /* SGTorch.m in Sources */ = {isa = PBXBuildFile; fileRef = 8D82F2392879A9EA00B72DE9 /* SGTorch.m */; };
32 | 8D82F23F2879C2A000B72DE9 /* MyQRCodeVC.m in Sources */ = {isa = PBXBuildFile; fileRef = 8D82F23E2879C2A000B72DE9 /* MyQRCodeVC.m */; };
33 | 8D893AF7287BBE5600CF3D7E /* QQQRCodeVC.m in Sources */ = {isa = PBXBuildFile; fileRef = 8D893AF6287BBE5600CF3D7E /* QQQRCodeVC.m */; };
34 | 8D893AFA287BBE7000CF3D7E /* XCQRCodeVC.m in Sources */ = {isa = PBXBuildFile; fileRef = 8D893AF9287BBE7000CF3D7E /* XCQRCodeVC.m */; };
35 | 8D97EF67269325F700F30558 /* SGScanView.m in Sources */ = {isa = PBXBuildFile; fileRef = 8D97EF65269325F700F30558 /* SGScanView.m */; };
36 | 8D97EF6A2693272A00F30558 /* SGGenerateQRCode.m in Sources */ = {isa = PBXBuildFile; fileRef = 8D97EF692693272A00F30558 /* SGGenerateQRCode.m */; };
37 | /* End PBXBuildFile section */
38 |
39 | /* Begin PBXContainerItemProxy section */
40 | 18479EE41E80F92500F7F225 /* PBXContainerItemProxy */ = {
41 | isa = PBXContainerItemProxy;
42 | containerPortal = 18479EC21E80F92500F7F225 /* Project object */;
43 | proxyType = 1;
44 | remoteGlobalIDString = 18479EC91E80F92500F7F225;
45 | remoteInfo = SGQRCodeExample;
46 | };
47 | 18479EEF1E80F92500F7F225 /* PBXContainerItemProxy */ = {
48 | isa = PBXContainerItemProxy;
49 | containerPortal = 18479EC21E80F92500F7F225 /* Project object */;
50 | proxyType = 1;
51 | remoteGlobalIDString = 18479EC91E80F92500F7F225;
52 | remoteInfo = SGQRCodeExample;
53 | };
54 | /* End PBXContainerItemProxy section */
55 |
56 | /* Begin PBXFileReference section */
57 | 180E36071F01F33E00A53E7A /* WebViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebViewController.h; sourceTree = ""; };
58 | 180E36081F01F33E00A53E7A /* WebViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = WebViewController.m; sourceTree = ""; };
59 | 18479ECA1E80F92500F7F225 /* SGQRCodeExample.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = SGQRCodeExample.app; sourceTree = BUILT_PRODUCTS_DIR; };
60 | 18479ECE1E80F92500F7F225 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; };
61 | 18479ED01E80F92500F7F225 /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; };
62 | 18479ED11E80F92500F7F225 /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; };
63 | 18479ED91E80F92500F7F225 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; };
64 | 18479EDC1E80F92500F7F225 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; };
65 | 18479EDE1E80F92500F7F225 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; };
66 | 18479EE31E80F92500F7F225 /* SGQRCodeExampleTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = SGQRCodeExampleTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
67 | 18479EE71E80F92500F7F225 /* SGQRCodeExampleTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SGQRCodeExampleTests.m; sourceTree = ""; };
68 | 18479EE91E80F92500F7F225 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; };
69 | 18479EEE1E80F92500F7F225 /* SGQRCodeExampleUITests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = SGQRCodeExampleUITests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
70 | 18479EF21E80F92500F7F225 /* SGQRCodeExampleUITests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SGQRCodeExampleUITests.m; sourceTree = ""; };
71 | 18479EF41E80F92500F7F225 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; };
72 | 18479F061E80F97600F7F225 /* ViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ViewController.h; sourceTree = ""; };
73 | 18479F071E80F97700F7F225 /* ViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ViewController.m; sourceTree = ""; };
74 | 18479F101E80F98F00F7F225 /* SGQRCode.bundle */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.plug-in"; path = SGQRCode.bundle; sourceTree = ""; };
75 | 18479F111E80F98F00F7F225 /* SGQRCode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SGQRCode.h; sourceTree = ""; };
76 | 18479F1E1E80F9CA00F7F225 /* Main.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; path = Main.storyboard; sourceTree = ""; };
77 | 8D19272C210DFF87002AE63A /* WBQRCodeVC.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WBQRCodeVC.h; sourceTree = ""; };
78 | 8D19272D210DFF88002AE63A /* WBQRCodeVC.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = WBQRCodeVC.m; sourceTree = ""; };
79 | 8D3DFEFC2662984800E02474 /* SGScanCode.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SGScanCode.h; sourceTree = ""; };
80 | 8D3DFEFD2662984800E02474 /* SGScanCode.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SGScanCode.m; sourceTree = ""; };
81 | 8D805A692880EC1600E91BC4 /* SGQRCodeLog.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SGQRCodeLog.h; sourceTree = ""; };
82 | 8D805A6A2880EC1600E91BC4 /* SGQRCodeLog.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SGQRCodeLog.m; sourceTree = ""; };
83 | 8D82F1F928781C5D00B72DE9 /* SGPermission.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SGPermission.h; sourceTree = ""; };
84 | 8D82F1FA28781C5D00B72DE9 /* SGPermission.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SGPermission.m; sourceTree = ""; };
85 | 8D82F1FC28781DEF00B72DE9 /* SGPermissionCamera.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SGPermissionCamera.h; sourceTree = ""; };
86 | 8D82F1FD28781DEF00B72DE9 /* SGPermissionCamera.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SGPermissionCamera.m; sourceTree = ""; };
87 | 8D82F205287834E200B72DE9 /* SGPermissionPhoto.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SGPermissionPhoto.h; sourceTree = ""; };
88 | 8D82F206287834E200B72DE9 /* SGPermissionPhoto.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SGPermissionPhoto.m; sourceTree = ""; };
89 | 8D82F209287859DB00B72DE9 /* SGScanCodeDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SGScanCodeDelegate.h; sourceTree = ""; };
90 | 8D82F20C28785C0C00B72DE9 /* SGSoundEffect.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SGSoundEffect.h; sourceTree = ""; };
91 | 8D82F20D28785C0C00B72DE9 /* SGSoundEffect.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SGSoundEffect.m; sourceTree = ""; };
92 | 8D82F2122879166000B72DE9 /* SGScanViewConfigure.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SGScanViewConfigure.h; sourceTree = ""; };
93 | 8D82F2132879166000B72DE9 /* SGScanViewConfigure.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SGScanViewConfigure.m; sourceTree = ""; };
94 | 8D82F21628794E2500B72DE9 /* SGWeakProxy.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SGWeakProxy.h; sourceTree = ""; };
95 | 8D82F21728794E2500B72DE9 /* SGWeakProxy.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SGWeakProxy.m; sourceTree = ""; };
96 | 8D82F22728798D1F00B72DE9 /* WCQRCodeVC.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = WCQRCodeVC.m; sourceTree = ""; };
97 | 8D82F22828798D1F00B72DE9 /* WCQRCodeVC.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WCQRCodeVC.h; sourceTree = ""; };
98 | 8D82F22A28798FEA00B72DE9 /* WCToolBar.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WCToolBar.h; sourceTree = ""; };
99 | 8D82F22B28798FEA00B72DE9 /* WCToolBar.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = WCToolBar.m; sourceTree = ""; };
100 | 8D82F2382879A9EA00B72DE9 /* SGTorch.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SGTorch.h; sourceTree = ""; };
101 | 8D82F2392879A9EA00B72DE9 /* SGTorch.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SGTorch.m; sourceTree = ""; };
102 | 8D82F23D2879C2A000B72DE9 /* MyQRCodeVC.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MyQRCodeVC.h; sourceTree = ""; };
103 | 8D82F23E2879C2A000B72DE9 /* MyQRCodeVC.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MyQRCodeVC.m; sourceTree = ""; };
104 | 8D893AF5287BBE5600CF3D7E /* QQQRCodeVC.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = QQQRCodeVC.h; sourceTree = ""; };
105 | 8D893AF6287BBE5600CF3D7E /* QQQRCodeVC.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = QQQRCodeVC.m; sourceTree = ""; };
106 | 8D893AF8287BBE7000CF3D7E /* XCQRCodeVC.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = XCQRCodeVC.h; sourceTree = ""; };
107 | 8D893AF9287BBE7000CF3D7E /* XCQRCodeVC.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = XCQRCodeVC.m; sourceTree = ""; };
108 | 8D97EF62269325F700F30558 /* SGScanView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SGScanView.h; sourceTree = ""; };
109 | 8D97EF65269325F700F30558 /* SGScanView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SGScanView.m; sourceTree = ""; };
110 | 8D97EF682693272A00F30558 /* SGGenerateQRCode.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SGGenerateQRCode.h; sourceTree = ""; };
111 | 8D97EF692693272A00F30558 /* SGGenerateQRCode.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SGGenerateQRCode.m; sourceTree = ""; };
112 | /* End PBXFileReference section */
113 |
114 | /* Begin PBXFrameworksBuildPhase section */
115 | 18479EC71E80F92500F7F225 /* Frameworks */ = {
116 | isa = PBXFrameworksBuildPhase;
117 | buildActionMask = 2147483647;
118 | files = (
119 | );
120 | runOnlyForDeploymentPostprocessing = 0;
121 | };
122 | 18479EE01E80F92500F7F225 /* Frameworks */ = {
123 | isa = PBXFrameworksBuildPhase;
124 | buildActionMask = 2147483647;
125 | files = (
126 | );
127 | runOnlyForDeploymentPostprocessing = 0;
128 | };
129 | 18479EEB1E80F92500F7F225 /* Frameworks */ = {
130 | isa = PBXFrameworksBuildPhase;
131 | buildActionMask = 2147483647;
132 | files = (
133 | );
134 | runOnlyForDeploymentPostprocessing = 0;
135 | };
136 | /* End PBXFrameworksBuildPhase section */
137 |
138 | /* Begin PBXGroup section */
139 | 180E36041F01F33E00A53E7A /* WebView */ = {
140 | isa = PBXGroup;
141 | children = (
142 | 180E36071F01F33E00A53E7A /* WebViewController.h */,
143 | 180E36081F01F33E00A53E7A /* WebViewController.m */,
144 | );
145 | path = WebView;
146 | sourceTree = "";
147 | };
148 | 18479EC11E80F92500F7F225 = {
149 | isa = PBXGroup;
150 | children = (
151 | 18479F0C1E80F98F00F7F225 /* SGQRCode */,
152 | 18479ECC1E80F92500F7F225 /* SGQRCodeExample */,
153 | 18479EE61E80F92500F7F225 /* SGQRCodeExampleTests */,
154 | 18479EF11E80F92500F7F225 /* SGQRCodeExampleUITests */,
155 | 18479ECB1E80F92500F7F225 /* Products */,
156 | );
157 | sourceTree = "";
158 | };
159 | 18479ECB1E80F92500F7F225 /* Products */ = {
160 | isa = PBXGroup;
161 | children = (
162 | 18479ECA1E80F92500F7F225 /* SGQRCodeExample.app */,
163 | 18479EE31E80F92500F7F225 /* SGQRCodeExampleTests.xctest */,
164 | 18479EEE1E80F92500F7F225 /* SGQRCodeExampleUITests.xctest */,
165 | );
166 | name = Products;
167 | sourceTree = "";
168 | };
169 | 18479ECC1E80F92500F7F225 /* SGQRCodeExample */ = {
170 | isa = PBXGroup;
171 | children = (
172 | 18479ED01E80F92500F7F225 /* AppDelegate.h */,
173 | 18479ED11E80F92500F7F225 /* AppDelegate.m */,
174 | 18479F061E80F97600F7F225 /* ViewController.h */,
175 | 18479F071E80F97700F7F225 /* ViewController.m */,
176 | 8D82F21E28798C5E00B72DE9 /* WC */,
177 | 8D893AF1287BBE0F00CF3D7E /* QQ */,
178 | 8D893AF2287BBE1F00CF3D7E /* XC */,
179 | 8D82F240287A59A200B72DE9 /* WB */,
180 | 8D82F23C2879C28000B72DE9 /* MyQRCode */,
181 | 180E36041F01F33E00A53E7A /* WebView */,
182 | 18479F1E1E80F9CA00F7F225 /* Main.storyboard */,
183 | 18479ED91E80F92500F7F225 /* Assets.xcassets */,
184 | 18479EDB1E80F92500F7F225 /* LaunchScreen.storyboard */,
185 | 18479EDE1E80F92500F7F225 /* Info.plist */,
186 | 18479ECD1E80F92500F7F225 /* Supporting Files */,
187 | );
188 | path = SGQRCodeExample;
189 | sourceTree = "";
190 | };
191 | 18479ECD1E80F92500F7F225 /* Supporting Files */ = {
192 | isa = PBXGroup;
193 | children = (
194 | 18479ECE1E80F92500F7F225 /* main.m */,
195 | );
196 | name = "Supporting Files";
197 | sourceTree = "";
198 | };
199 | 18479EE61E80F92500F7F225 /* SGQRCodeExampleTests */ = {
200 | isa = PBXGroup;
201 | children = (
202 | 18479EE71E80F92500F7F225 /* SGQRCodeExampleTests.m */,
203 | 18479EE91E80F92500F7F225 /* Info.plist */,
204 | );
205 | path = SGQRCodeExampleTests;
206 | sourceTree = "";
207 | };
208 | 18479EF11E80F92500F7F225 /* SGQRCodeExampleUITests */ = {
209 | isa = PBXGroup;
210 | children = (
211 | 18479EF21E80F92500F7F225 /* SGQRCodeExampleUITests.m */,
212 | 18479EF41E80F92500F7F225 /* Info.plist */,
213 | );
214 | path = SGQRCodeExampleUITests;
215 | sourceTree = "";
216 | };
217 | 18479F0C1E80F98F00F7F225 /* SGQRCode */ = {
218 | isa = PBXGroup;
219 | children = (
220 | 18479F111E80F98F00F7F225 /* SGQRCode.h */,
221 | 8D805A692880EC1600E91BC4 /* SGQRCodeLog.h */,
222 | 8D805A6A2880EC1600E91BC4 /* SGQRCodeLog.m */,
223 | 8D80F188288246EA00BB415B /* QRCode */,
224 | 8D82F2152879168000B72DE9 /* ScanView */,
225 | 8D82F2082878381000B72DE9 /* Permission */,
226 | 8D82F211287860BF00B72DE9 /* SoundEffect */,
227 | 8D82F2372879A9D600B72DE9 /* Torch */,
228 | 8D82F23B2879B5E900B72DE9 /* WeakProxy */,
229 | 18479F101E80F98F00F7F225 /* SGQRCode.bundle */,
230 | );
231 | path = SGQRCode;
232 | sourceTree = "";
233 | };
234 | 8D80F188288246EA00BB415B /* QRCode */ = {
235 | isa = PBXGroup;
236 | children = (
237 | 8D97EF682693272A00F30558 /* SGGenerateQRCode.h */,
238 | 8D97EF692693272A00F30558 /* SGGenerateQRCode.m */,
239 | 8D3DFEFC2662984800E02474 /* SGScanCode.h */,
240 | 8D3DFEFD2662984800E02474 /* SGScanCode.m */,
241 | 8D82F209287859DB00B72DE9 /* SGScanCodeDelegate.h */,
242 | );
243 | path = QRCode;
244 | sourceTree = "";
245 | };
246 | 8D82F2082878381000B72DE9 /* Permission */ = {
247 | isa = PBXGroup;
248 | children = (
249 | 8D82F1F928781C5D00B72DE9 /* SGPermission.h */,
250 | 8D82F1FA28781C5D00B72DE9 /* SGPermission.m */,
251 | 8D82F1FC28781DEF00B72DE9 /* SGPermissionCamera.h */,
252 | 8D82F1FD28781DEF00B72DE9 /* SGPermissionCamera.m */,
253 | 8D82F205287834E200B72DE9 /* SGPermissionPhoto.h */,
254 | 8D82F206287834E200B72DE9 /* SGPermissionPhoto.m */,
255 | );
256 | path = Permission;
257 | sourceTree = "";
258 | };
259 | 8D82F211287860BF00B72DE9 /* SoundEffect */ = {
260 | isa = PBXGroup;
261 | children = (
262 | 8D82F20C28785C0C00B72DE9 /* SGSoundEffect.h */,
263 | 8D82F20D28785C0C00B72DE9 /* SGSoundEffect.m */,
264 | );
265 | path = SoundEffect;
266 | sourceTree = "";
267 | };
268 | 8D82F2152879168000B72DE9 /* ScanView */ = {
269 | isa = PBXGroup;
270 | children = (
271 | 8D82F2122879166000B72DE9 /* SGScanViewConfigure.h */,
272 | 8D82F2132879166000B72DE9 /* SGScanViewConfigure.m */,
273 | 8D97EF62269325F700F30558 /* SGScanView.h */,
274 | 8D97EF65269325F700F30558 /* SGScanView.m */,
275 | );
276 | path = ScanView;
277 | sourceTree = "";
278 | };
279 | 8D82F21E28798C5E00B72DE9 /* WC */ = {
280 | isa = PBXGroup;
281 | children = (
282 | 8D82F22628798D1900B72DE9 /* Controller */,
283 | 8D82F21F28798C7900B72DE9 /* View */,
284 | );
285 | path = WC;
286 | sourceTree = "";
287 | };
288 | 8D82F21F28798C7900B72DE9 /* View */ = {
289 | isa = PBXGroup;
290 | children = (
291 | 8D82F22A28798FEA00B72DE9 /* WCToolBar.h */,
292 | 8D82F22B28798FEA00B72DE9 /* WCToolBar.m */,
293 | );
294 | path = View;
295 | sourceTree = "";
296 | };
297 | 8D82F22628798D1900B72DE9 /* Controller */ = {
298 | isa = PBXGroup;
299 | children = (
300 | 8D82F22828798D1F00B72DE9 /* WCQRCodeVC.h */,
301 | 8D82F22728798D1F00B72DE9 /* WCQRCodeVC.m */,
302 | );
303 | path = Controller;
304 | sourceTree = "";
305 | };
306 | 8D82F2372879A9D600B72DE9 /* Torch */ = {
307 | isa = PBXGroup;
308 | children = (
309 | 8D82F2382879A9EA00B72DE9 /* SGTorch.h */,
310 | 8D82F2392879A9EA00B72DE9 /* SGTorch.m */,
311 | );
312 | path = Torch;
313 | sourceTree = "";
314 | };
315 | 8D82F23B2879B5E900B72DE9 /* WeakProxy */ = {
316 | isa = PBXGroup;
317 | children = (
318 | 8D82F21628794E2500B72DE9 /* SGWeakProxy.h */,
319 | 8D82F21728794E2500B72DE9 /* SGWeakProxy.m */,
320 | );
321 | path = WeakProxy;
322 | sourceTree = "";
323 | };
324 | 8D82F23C2879C28000B72DE9 /* MyQRCode */ = {
325 | isa = PBXGroup;
326 | children = (
327 | 8D82F23D2879C2A000B72DE9 /* MyQRCodeVC.h */,
328 | 8D82F23E2879C2A000B72DE9 /* MyQRCodeVC.m */,
329 | );
330 | path = MyQRCode;
331 | sourceTree = "";
332 | };
333 | 8D82F240287A59A200B72DE9 /* WB */ = {
334 | isa = PBXGroup;
335 | children = (
336 | 8D82F241287A59BC00B72DE9 /* Controller */,
337 | );
338 | path = WB;
339 | sourceTree = "";
340 | };
341 | 8D82F241287A59BC00B72DE9 /* Controller */ = {
342 | isa = PBXGroup;
343 | children = (
344 | 8D19272C210DFF87002AE63A /* WBQRCodeVC.h */,
345 | 8D19272D210DFF88002AE63A /* WBQRCodeVC.m */,
346 | );
347 | path = Controller;
348 | sourceTree = "";
349 | };
350 | 8D893AF1287BBE0F00CF3D7E /* QQ */ = {
351 | isa = PBXGroup;
352 | children = (
353 | 8D893AF3287BBE3500CF3D7E /* Controller */,
354 | );
355 | path = QQ;
356 | sourceTree = "";
357 | };
358 | 8D893AF2287BBE1F00CF3D7E /* XC */ = {
359 | isa = PBXGroup;
360 | children = (
361 | 8D893AF4287BBE3B00CF3D7E /* Controller */,
362 | );
363 | path = XC;
364 | sourceTree = "";
365 | };
366 | 8D893AF3287BBE3500CF3D7E /* Controller */ = {
367 | isa = PBXGroup;
368 | children = (
369 | 8D893AF5287BBE5600CF3D7E /* QQQRCodeVC.h */,
370 | 8D893AF6287BBE5600CF3D7E /* QQQRCodeVC.m */,
371 | );
372 | path = Controller;
373 | sourceTree = "";
374 | };
375 | 8D893AF4287BBE3B00CF3D7E /* Controller */ = {
376 | isa = PBXGroup;
377 | children = (
378 | 8D893AF8287BBE7000CF3D7E /* XCQRCodeVC.h */,
379 | 8D893AF9287BBE7000CF3D7E /* XCQRCodeVC.m */,
380 | );
381 | path = Controller;
382 | sourceTree = "";
383 | };
384 | /* End PBXGroup section */
385 |
386 | /* Begin PBXNativeTarget section */
387 | 18479EC91E80F92500F7F225 /* SGQRCodeExample */ = {
388 | isa = PBXNativeTarget;
389 | buildConfigurationList = 18479EF71E80F92500F7F225 /* Build configuration list for PBXNativeTarget "SGQRCodeExample" */;
390 | buildPhases = (
391 | 18479EC61E80F92500F7F225 /* Sources */,
392 | 18479EC71E80F92500F7F225 /* Frameworks */,
393 | 18479EC81E80F92500F7F225 /* Resources */,
394 | );
395 | buildRules = (
396 | );
397 | dependencies = (
398 | );
399 | name = SGQRCodeExample;
400 | productName = SGQRCodeExample;
401 | productReference = 18479ECA1E80F92500F7F225 /* SGQRCodeExample.app */;
402 | productType = "com.apple.product-type.application";
403 | };
404 | 18479EE21E80F92500F7F225 /* SGQRCodeExampleTests */ = {
405 | isa = PBXNativeTarget;
406 | buildConfigurationList = 18479EFA1E80F92500F7F225 /* Build configuration list for PBXNativeTarget "SGQRCodeExampleTests" */;
407 | buildPhases = (
408 | 18479EDF1E80F92500F7F225 /* Sources */,
409 | 18479EE01E80F92500F7F225 /* Frameworks */,
410 | 18479EE11E80F92500F7F225 /* Resources */,
411 | );
412 | buildRules = (
413 | );
414 | dependencies = (
415 | 18479EE51E80F92500F7F225 /* PBXTargetDependency */,
416 | );
417 | name = SGQRCodeExampleTests;
418 | productName = SGQRCodeExampleTests;
419 | productReference = 18479EE31E80F92500F7F225 /* SGQRCodeExampleTests.xctest */;
420 | productType = "com.apple.product-type.bundle.unit-test";
421 | };
422 | 18479EED1E80F92500F7F225 /* SGQRCodeExampleUITests */ = {
423 | isa = PBXNativeTarget;
424 | buildConfigurationList = 18479EFD1E80F92500F7F225 /* Build configuration list for PBXNativeTarget "SGQRCodeExampleUITests" */;
425 | buildPhases = (
426 | 18479EEA1E80F92500F7F225 /* Sources */,
427 | 18479EEB1E80F92500F7F225 /* Frameworks */,
428 | 18479EEC1E80F92500F7F225 /* Resources */,
429 | );
430 | buildRules = (
431 | );
432 | dependencies = (
433 | 18479EF01E80F92500F7F225 /* PBXTargetDependency */,
434 | );
435 | name = SGQRCodeExampleUITests;
436 | productName = SGQRCodeExampleUITests;
437 | productReference = 18479EEE1E80F92500F7F225 /* SGQRCodeExampleUITests.xctest */;
438 | productType = "com.apple.product-type.bundle.ui-testing";
439 | };
440 | /* End PBXNativeTarget section */
441 |
442 | /* Begin PBXProject section */
443 | 18479EC21E80F92500F7F225 /* Project object */ = {
444 | isa = PBXProject;
445 | attributes = {
446 | LastUpgradeCheck = 1240;
447 | ORGANIZATIONNAME = Sorgle;
448 | TargetAttributes = {
449 | 18479EC91E80F92500F7F225 = {
450 | CreatedOnToolsVersion = 8.2.1;
451 | ProvisioningStyle = Automatic;
452 | };
453 | 18479EE21E80F92500F7F225 = {
454 | CreatedOnToolsVersion = 8.2.1;
455 | ProvisioningStyle = Automatic;
456 | TestTargetID = 18479EC91E80F92500F7F225;
457 | };
458 | 18479EED1E80F92500F7F225 = {
459 | CreatedOnToolsVersion = 8.2.1;
460 | ProvisioningStyle = Automatic;
461 | TestTargetID = 18479EC91E80F92500F7F225;
462 | };
463 | };
464 | };
465 | buildConfigurationList = 18479EC51E80F92500F7F225 /* Build configuration list for PBXProject "SGQRCodeExample" */;
466 | compatibilityVersion = "Xcode 3.2";
467 | developmentRegion = en;
468 | hasScannedForEncodings = 0;
469 | knownRegions = (
470 | en,
471 | Base,
472 | );
473 | mainGroup = 18479EC11E80F92500F7F225;
474 | productRefGroup = 18479ECB1E80F92500F7F225 /* Products */;
475 | projectDirPath = "";
476 | projectRoot = "";
477 | targets = (
478 | 18479EC91E80F92500F7F225 /* SGQRCodeExample */,
479 | 18479EE21E80F92500F7F225 /* SGQRCodeExampleTests */,
480 | 18479EED1E80F92500F7F225 /* SGQRCodeExampleUITests */,
481 | );
482 | };
483 | /* End PBXProject section */
484 |
485 | /* Begin PBXResourcesBuildPhase section */
486 | 18479EC81E80F92500F7F225 /* Resources */ = {
487 | isa = PBXResourcesBuildPhase;
488 | buildActionMask = 2147483647;
489 | files = (
490 | 18479EDD1E80F92500F7F225 /* LaunchScreen.storyboard in Resources */,
491 | 18479EDA1E80F92500F7F225 /* Assets.xcassets in Resources */,
492 | 18479F1A1E80F98F00F7F225 /* SGQRCode.bundle in Resources */,
493 | 18479F1F1E80F9CA00F7F225 /* Main.storyboard in Resources */,
494 | );
495 | runOnlyForDeploymentPostprocessing = 0;
496 | };
497 | 18479EE11E80F92500F7F225 /* Resources */ = {
498 | isa = PBXResourcesBuildPhase;
499 | buildActionMask = 2147483647;
500 | files = (
501 | );
502 | runOnlyForDeploymentPostprocessing = 0;
503 | };
504 | 18479EEC1E80F92500F7F225 /* Resources */ = {
505 | isa = PBXResourcesBuildPhase;
506 | buildActionMask = 2147483647;
507 | files = (
508 | );
509 | runOnlyForDeploymentPostprocessing = 0;
510 | };
511 | /* End PBXResourcesBuildPhase section */
512 |
513 | /* Begin PBXSourcesBuildPhase section */
514 | 18479EC61E80F92500F7F225 /* Sources */ = {
515 | isa = PBXSourcesBuildPhase;
516 | buildActionMask = 2147483647;
517 | files = (
518 | 8D19272E210DFF88002AE63A /* WBQRCodeVC.m in Sources */,
519 | 8D82F1FE28781DEF00B72DE9 /* SGPermissionCamera.m in Sources */,
520 | 18479F0B1E80F97700F7F225 /* ViewController.m in Sources */,
521 | 180E360F1F01F33E00A53E7A /* WebViewController.m in Sources */,
522 | 8D82F21828794E2500B72DE9 /* SGWeakProxy.m in Sources */,
523 | 8D82F23F2879C2A000B72DE9 /* MyQRCodeVC.m in Sources */,
524 | 8D805A6B2880EC1600E91BC4 /* SGQRCodeLog.m in Sources */,
525 | 8D893AF7287BBE5600CF3D7E /* QQQRCodeVC.m in Sources */,
526 | 8D82F22C28798FEA00B72DE9 /* WCToolBar.m in Sources */,
527 | 8D82F22928798D1F00B72DE9 /* WCQRCodeVC.m in Sources */,
528 | 8D97EF6A2693272A00F30558 /* SGGenerateQRCode.m in Sources */,
529 | 8D82F1FB28781C5D00B72DE9 /* SGPermission.m in Sources */,
530 | 18479ED21E80F92500F7F225 /* AppDelegate.m in Sources */,
531 | 8D82F20E28785C0C00B72DE9 /* SGSoundEffect.m in Sources */,
532 | 8D82F2142879166000B72DE9 /* SGScanViewConfigure.m in Sources */,
533 | 8D3DFEFE2662984800E02474 /* SGScanCode.m in Sources */,
534 | 8D82F23A2879A9EA00B72DE9 /* SGTorch.m in Sources */,
535 | 8D97EF67269325F700F30558 /* SGScanView.m in Sources */,
536 | 8D82F207287834E200B72DE9 /* SGPermissionPhoto.m in Sources */,
537 | 18479ECF1E80F92500F7F225 /* main.m in Sources */,
538 | 8D893AFA287BBE7000CF3D7E /* XCQRCodeVC.m in Sources */,
539 | );
540 | runOnlyForDeploymentPostprocessing = 0;
541 | };
542 | 18479EDF1E80F92500F7F225 /* Sources */ = {
543 | isa = PBXSourcesBuildPhase;
544 | buildActionMask = 2147483647;
545 | files = (
546 | 18479EE81E80F92500F7F225 /* SGQRCodeExampleTests.m in Sources */,
547 | );
548 | runOnlyForDeploymentPostprocessing = 0;
549 | };
550 | 18479EEA1E80F92500F7F225 /* Sources */ = {
551 | isa = PBXSourcesBuildPhase;
552 | buildActionMask = 2147483647;
553 | files = (
554 | 18479EF31E80F92500F7F225 /* SGQRCodeExampleUITests.m in Sources */,
555 | );
556 | runOnlyForDeploymentPostprocessing = 0;
557 | };
558 | /* End PBXSourcesBuildPhase section */
559 |
560 | /* Begin PBXTargetDependency section */
561 | 18479EE51E80F92500F7F225 /* PBXTargetDependency */ = {
562 | isa = PBXTargetDependency;
563 | target = 18479EC91E80F92500F7F225 /* SGQRCodeExample */;
564 | targetProxy = 18479EE41E80F92500F7F225 /* PBXContainerItemProxy */;
565 | };
566 | 18479EF01E80F92500F7F225 /* PBXTargetDependency */ = {
567 | isa = PBXTargetDependency;
568 | target = 18479EC91E80F92500F7F225 /* SGQRCodeExample */;
569 | targetProxy = 18479EEF1E80F92500F7F225 /* PBXContainerItemProxy */;
570 | };
571 | /* End PBXTargetDependency section */
572 |
573 | /* Begin PBXVariantGroup section */
574 | 18479EDB1E80F92500F7F225 /* LaunchScreen.storyboard */ = {
575 | isa = PBXVariantGroup;
576 | children = (
577 | 18479EDC1E80F92500F7F225 /* Base */,
578 | );
579 | name = LaunchScreen.storyboard;
580 | sourceTree = "";
581 | };
582 | /* End PBXVariantGroup section */
583 |
584 | /* Begin XCBuildConfiguration section */
585 | 18479EF51E80F92500F7F225 /* Debug */ = {
586 | isa = XCBuildConfiguration;
587 | buildSettings = {
588 | ALWAYS_SEARCH_USER_PATHS = NO;
589 | CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES;
590 | CLANG_ANALYZER_NONNULL = YES;
591 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
592 | CLANG_CXX_LIBRARY = "libc++";
593 | CLANG_ENABLE_MODULES = YES;
594 | CLANG_ENABLE_OBJC_ARC = YES;
595 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
596 | CLANG_WARN_BOOL_CONVERSION = YES;
597 | CLANG_WARN_COMMA = YES;
598 | CLANG_WARN_CONSTANT_CONVERSION = YES;
599 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
600 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
601 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
602 | CLANG_WARN_EMPTY_BODY = YES;
603 | CLANG_WARN_ENUM_CONVERSION = YES;
604 | CLANG_WARN_INFINITE_RECURSION = YES;
605 | CLANG_WARN_INT_CONVERSION = YES;
606 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
607 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
608 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
609 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
610 | CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
611 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
612 | CLANG_WARN_STRICT_PROTOTYPES = YES;
613 | CLANG_WARN_SUSPICIOUS_MOVE = YES;
614 | CLANG_WARN_UNREACHABLE_CODE = YES;
615 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
616 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
617 | COPY_PHASE_STRIP = NO;
618 | DEBUG_INFORMATION_FORMAT = dwarf;
619 | ENABLE_STRICT_OBJC_MSGSEND = YES;
620 | ENABLE_TESTABILITY = YES;
621 | GCC_C_LANGUAGE_STANDARD = gnu99;
622 | GCC_DYNAMIC_NO_PIC = NO;
623 | GCC_NO_COMMON_BLOCKS = YES;
624 | GCC_OPTIMIZATION_LEVEL = 0;
625 | GCC_PREPROCESSOR_DEFINITIONS = (
626 | "DEBUG=1",
627 | "$(inherited)",
628 | );
629 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
630 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
631 | GCC_WARN_UNDECLARED_SELECTOR = YES;
632 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
633 | GCC_WARN_UNUSED_FUNCTION = YES;
634 | GCC_WARN_UNUSED_VARIABLE = YES;
635 | IPHONEOS_DEPLOYMENT_TARGET = 12.0;
636 | MTL_ENABLE_DEBUG_INFO = YES;
637 | ONLY_ACTIVE_ARCH = YES;
638 | SDKROOT = iphoneos;
639 | };
640 | name = Debug;
641 | };
642 | 18479EF61E80F92500F7F225 /* Release */ = {
643 | isa = XCBuildConfiguration;
644 | buildSettings = {
645 | ALWAYS_SEARCH_USER_PATHS = NO;
646 | CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES;
647 | CLANG_ANALYZER_NONNULL = YES;
648 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
649 | CLANG_CXX_LIBRARY = "libc++";
650 | CLANG_ENABLE_MODULES = YES;
651 | CLANG_ENABLE_OBJC_ARC = YES;
652 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
653 | CLANG_WARN_BOOL_CONVERSION = YES;
654 | CLANG_WARN_COMMA = YES;
655 | CLANG_WARN_CONSTANT_CONVERSION = YES;
656 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
657 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
658 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
659 | CLANG_WARN_EMPTY_BODY = YES;
660 | CLANG_WARN_ENUM_CONVERSION = YES;
661 | CLANG_WARN_INFINITE_RECURSION = YES;
662 | CLANG_WARN_INT_CONVERSION = YES;
663 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
664 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
665 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
666 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
667 | CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
668 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
669 | CLANG_WARN_STRICT_PROTOTYPES = YES;
670 | CLANG_WARN_SUSPICIOUS_MOVE = YES;
671 | CLANG_WARN_UNREACHABLE_CODE = YES;
672 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
673 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
674 | COPY_PHASE_STRIP = NO;
675 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
676 | ENABLE_NS_ASSERTIONS = NO;
677 | ENABLE_STRICT_OBJC_MSGSEND = YES;
678 | GCC_C_LANGUAGE_STANDARD = gnu99;
679 | GCC_NO_COMMON_BLOCKS = YES;
680 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
681 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
682 | GCC_WARN_UNDECLARED_SELECTOR = YES;
683 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
684 | GCC_WARN_UNUSED_FUNCTION = YES;
685 | GCC_WARN_UNUSED_VARIABLE = YES;
686 | IPHONEOS_DEPLOYMENT_TARGET = 12.0;
687 | MTL_ENABLE_DEBUG_INFO = NO;
688 | SDKROOT = iphoneos;
689 | VALIDATE_PRODUCT = YES;
690 | };
691 | name = Release;
692 | };
693 | 18479EF81E80F92500F7F225 /* Debug */ = {
694 | isa = XCBuildConfiguration;
695 | buildSettings = {
696 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
697 | CODE_SIGN_IDENTITY = "iPhone Developer";
698 | CODE_SIGN_STYLE = Automatic;
699 | DEVELOPMENT_TEAM = "";
700 | INFOPLIST_FILE = SGQRCodeExample/Info.plist;
701 | IPHONEOS_DEPLOYMENT_TARGET = 12.0;
702 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
703 | PRODUCT_BUNDLE_IDENTIFIER = com.SGQRCodeExample;
704 | PRODUCT_NAME = "$(TARGET_NAME)";
705 | PROVISIONING_PROFILE_SPECIFIER = "";
706 | };
707 | name = Debug;
708 | };
709 | 18479EF91E80F92500F7F225 /* Release */ = {
710 | isa = XCBuildConfiguration;
711 | buildSettings = {
712 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
713 | CODE_SIGN_IDENTITY = "iPhone Developer";
714 | CODE_SIGN_STYLE = Automatic;
715 | DEVELOPMENT_TEAM = "";
716 | INFOPLIST_FILE = SGQRCodeExample/Info.plist;
717 | IPHONEOS_DEPLOYMENT_TARGET = 12.0;
718 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
719 | PRODUCT_BUNDLE_IDENTIFIER = com.SGQRCodeExample;
720 | PRODUCT_NAME = "$(TARGET_NAME)";
721 | PROVISIONING_PROFILE_SPECIFIER = "";
722 | };
723 | name = Release;
724 | };
725 | 18479EFB1E80F92500F7F225 /* Debug */ = {
726 | isa = XCBuildConfiguration;
727 | buildSettings = {
728 | BUNDLE_LOADER = "$(TEST_HOST)";
729 | CODE_SIGN_IDENTITY = "Apple Development";
730 | "CODE_SIGN_IDENTITY[sdk=macosx*]" = "Apple Development";
731 | CODE_SIGN_STYLE = Automatic;
732 | DEVELOPMENT_TEAM = "";
733 | INFOPLIST_FILE = SGQRCodeExampleTests/Info.plist;
734 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
735 | PRODUCT_BUNDLE_IDENTIFIER = Sorgle.SGQRCodeExampleTests;
736 | PRODUCT_NAME = "$(TARGET_NAME)";
737 | PROVISIONING_PROFILE_SPECIFIER = "";
738 | "PROVISIONING_PROFILE_SPECIFIER[sdk=macosx*]" = "";
739 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/SGQRCodeExample.app/SGQRCodeExample";
740 | };
741 | name = Debug;
742 | };
743 | 18479EFC1E80F92500F7F225 /* Release */ = {
744 | isa = XCBuildConfiguration;
745 | buildSettings = {
746 | BUNDLE_LOADER = "$(TEST_HOST)";
747 | CODE_SIGN_IDENTITY = "Apple Development";
748 | "CODE_SIGN_IDENTITY[sdk=macosx*]" = "Apple Development";
749 | CODE_SIGN_STYLE = Automatic;
750 | DEVELOPMENT_TEAM = "";
751 | INFOPLIST_FILE = SGQRCodeExampleTests/Info.plist;
752 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
753 | PRODUCT_BUNDLE_IDENTIFIER = Sorgle.SGQRCodeExampleTests;
754 | PRODUCT_NAME = "$(TARGET_NAME)";
755 | PROVISIONING_PROFILE_SPECIFIER = "";
756 | "PROVISIONING_PROFILE_SPECIFIER[sdk=macosx*]" = "";
757 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/SGQRCodeExample.app/SGQRCodeExample";
758 | };
759 | name = Release;
760 | };
761 | 18479EFE1E80F92500F7F225 /* Debug */ = {
762 | isa = XCBuildConfiguration;
763 | buildSettings = {
764 | INFOPLIST_FILE = SGQRCodeExampleUITests/Info.plist;
765 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
766 | PRODUCT_BUNDLE_IDENTIFIER = Sorgle.SGQRCodeExampleUITests;
767 | PRODUCT_NAME = "$(TARGET_NAME)";
768 | TEST_TARGET_NAME = SGQRCodeExample;
769 | };
770 | name = Debug;
771 | };
772 | 18479EFF1E80F92500F7F225 /* Release */ = {
773 | isa = XCBuildConfiguration;
774 | buildSettings = {
775 | INFOPLIST_FILE = SGQRCodeExampleUITests/Info.plist;
776 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
777 | PRODUCT_BUNDLE_IDENTIFIER = Sorgle.SGQRCodeExampleUITests;
778 | PRODUCT_NAME = "$(TARGET_NAME)";
779 | TEST_TARGET_NAME = SGQRCodeExample;
780 | };
781 | name = Release;
782 | };
783 | /* End XCBuildConfiguration section */
784 |
785 | /* Begin XCConfigurationList section */
786 | 18479EC51E80F92500F7F225 /* Build configuration list for PBXProject "SGQRCodeExample" */ = {
787 | isa = XCConfigurationList;
788 | buildConfigurations = (
789 | 18479EF51E80F92500F7F225 /* Debug */,
790 | 18479EF61E80F92500F7F225 /* Release */,
791 | );
792 | defaultConfigurationIsVisible = 0;
793 | defaultConfigurationName = Release;
794 | };
795 | 18479EF71E80F92500F7F225 /* Build configuration list for PBXNativeTarget "SGQRCodeExample" */ = {
796 | isa = XCConfigurationList;
797 | buildConfigurations = (
798 | 18479EF81E80F92500F7F225 /* Debug */,
799 | 18479EF91E80F92500F7F225 /* Release */,
800 | );
801 | defaultConfigurationIsVisible = 0;
802 | defaultConfigurationName = Release;
803 | };
804 | 18479EFA1E80F92500F7F225 /* Build configuration list for PBXNativeTarget "SGQRCodeExampleTests" */ = {
805 | isa = XCConfigurationList;
806 | buildConfigurations = (
807 | 18479EFB1E80F92500F7F225 /* Debug */,
808 | 18479EFC1E80F92500F7F225 /* Release */,
809 | );
810 | defaultConfigurationIsVisible = 0;
811 | defaultConfigurationName = Release;
812 | };
813 | 18479EFD1E80F92500F7F225 /* Build configuration list for PBXNativeTarget "SGQRCodeExampleUITests" */ = {
814 | isa = XCConfigurationList;
815 | buildConfigurations = (
816 | 18479EFE1E80F92500F7F225 /* Debug */,
817 | 18479EFF1E80F92500F7F225 /* Release */,
818 | );
819 | defaultConfigurationIsVisible = 0;
820 | defaultConfigurationName = Release;
821 | };
822 | /* End XCConfigurationList section */
823 | };
824 | rootObject = 18479EC21E80F92500F7F225 /* Project object */;
825 | }
826 |
--------------------------------------------------------------------------------
/SGQRCodeExample.xcodeproj/project.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/SGQRCodeExample.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | IDEDidComputeMac32BitWarning
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/SGQRCodeExample/AppDelegate.h:
--------------------------------------------------------------------------------
1 | //
2 | // AppDelegate.h
3 | // SGQRCodeExample
4 | //
5 | // Created by kingsic on 17/3/21.
6 | // Copyright © 2017年 kingsic. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface AppDelegate : UIResponder
12 |
13 | @property (strong, nonatomic) UIWindow *window;
14 |
15 |
16 | @end
17 |
18 |
--------------------------------------------------------------------------------
/SGQRCodeExample/AppDelegate.m:
--------------------------------------------------------------------------------
1 | //
2 | // AppDelegate.m
3 | // SGQRCodeExample
4 | //
5 | // Created by kingsic on 17/3/21.
6 | // Copyright © 2017年 kingsic. All rights reserved.
7 | //
8 |
9 | #import "AppDelegate.h"
10 | #import "SGQRCode.h"
11 |
12 | @interface AppDelegate ()
13 |
14 | @end
15 |
16 | @implementation AppDelegate
17 |
18 |
19 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
20 | // Override point for customization after application launch.
21 |
22 | [[SGQRCodeLog sharedQRCodeLog] setLog:YES];
23 |
24 | return YES;
25 | }
26 |
27 |
28 | - (void)applicationWillResignActive:(UIApplication *)application {
29 | // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
30 | // Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game.
31 | }
32 |
33 |
34 | - (void)applicationDidEnterBackground:(UIApplication *)application {
35 | // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
36 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
37 | }
38 |
39 |
40 | - (void)applicationWillEnterForeground:(UIApplication *)application {
41 | // Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background.
42 | }
43 |
44 |
45 | - (void)applicationDidBecomeActive:(UIApplication *)application {
46 | // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
47 | }
48 |
49 |
50 | - (void)applicationWillTerminate:(UIApplication *)application {
51 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
52 | }
53 |
54 |
55 | @end
56 |
--------------------------------------------------------------------------------
/SGQRCodeExample/Assets.xcassets/AppIcon.appiconset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "iphone",
5 | "size" : "20x20",
6 | "scale" : "2x"
7 | },
8 | {
9 | "idiom" : "iphone",
10 | "size" : "20x20",
11 | "scale" : "3x"
12 | },
13 | {
14 | "idiom" : "iphone",
15 | "size" : "29x29",
16 | "scale" : "1x"
17 | },
18 | {
19 | "idiom" : "iphone",
20 | "size" : "29x29",
21 | "scale" : "2x"
22 | },
23 | {
24 | "idiom" : "iphone",
25 | "size" : "29x29",
26 | "scale" : "3x"
27 | },
28 | {
29 | "idiom" : "iphone",
30 | "size" : "40x40",
31 | "scale" : "2x"
32 | },
33 | {
34 | "idiom" : "iphone",
35 | "size" : "40x40",
36 | "scale" : "3x"
37 | },
38 | {
39 | "size" : "57x57",
40 | "idiom" : "iphone",
41 | "filename" : "icon.png",
42 | "scale" : "1x"
43 | },
44 | {
45 | "size" : "57x57",
46 | "idiom" : "iphone",
47 | "filename" : "icon57x57@2x.png",
48 | "scale" : "2x"
49 | },
50 | {
51 | "size" : "60x60",
52 | "idiom" : "iphone",
53 | "filename" : "icon60x60@2x.png",
54 | "scale" : "2x"
55 | },
56 | {
57 | "size" : "60x60",
58 | "idiom" : "iphone",
59 | "filename" : "icon60x60@3x.png",
60 | "scale" : "3x"
61 | },
62 | {
63 | "size" : "1024x1024",
64 | "idiom" : "ios-marketing",
65 | "filename" : "icon10240x10240.png",
66 | "scale" : "1x"
67 | }
68 | ],
69 | "info" : {
70 | "version" : 1,
71 | "author" : "xcode"
72 | }
73 | }
--------------------------------------------------------------------------------
/SGQRCodeExample/Assets.xcassets/AppIcon.appiconset/icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kingsic/SGQRCode/41f0640ba8b1e29576121acab72635a7c9c52d17/SGQRCodeExample/Assets.xcassets/AppIcon.appiconset/icon.png
--------------------------------------------------------------------------------
/SGQRCodeExample/Assets.xcassets/AppIcon.appiconset/icon10240x10240.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kingsic/SGQRCode/41f0640ba8b1e29576121acab72635a7c9c52d17/SGQRCodeExample/Assets.xcassets/AppIcon.appiconset/icon10240x10240.png
--------------------------------------------------------------------------------
/SGQRCodeExample/Assets.xcassets/AppIcon.appiconset/icon57x57@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kingsic/SGQRCode/41f0640ba8b1e29576121acab72635a7c9c52d17/SGQRCodeExample/Assets.xcassets/AppIcon.appiconset/icon57x57@2x.png
--------------------------------------------------------------------------------
/SGQRCodeExample/Assets.xcassets/AppIcon.appiconset/icon60x60@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kingsic/SGQRCode/41f0640ba8b1e29576121acab72635a7c9c52d17/SGQRCodeExample/Assets.xcassets/AppIcon.appiconset/icon60x60@2x.png
--------------------------------------------------------------------------------
/SGQRCodeExample/Assets.xcassets/AppIcon.appiconset/icon60x60@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kingsic/SGQRCode/41f0640ba8b1e29576121acab72635a7c9c52d17/SGQRCodeExample/Assets.xcassets/AppIcon.appiconset/icon60x60@3x.png
--------------------------------------------------------------------------------
/SGQRCodeExample/Assets.xcassets/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "info" : {
3 | "author" : "xcode",
4 | "version" : 1
5 | }
6 | }
7 |
--------------------------------------------------------------------------------
/SGQRCodeExample/Assets.xcassets/bg_image.imageset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "universal",
5 | "scale" : "1x"
6 | },
7 | {
8 | "idiom" : "universal",
9 | "filename" : "bg_image@2x.png",
10 | "scale" : "2x"
11 | },
12 | {
13 | "idiom" : "universal",
14 | "scale" : "3x"
15 | }
16 | ],
17 | "info" : {
18 | "version" : 1,
19 | "author" : "xcode"
20 | }
21 | }
--------------------------------------------------------------------------------
/SGQRCodeExample/Assets.xcassets/bg_image.imageset/bg_image@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kingsic/SGQRCode/41f0640ba8b1e29576121acab72635a7c9c52d17/SGQRCodeExample/Assets.xcassets/bg_image.imageset/bg_image@2x.png
--------------------------------------------------------------------------------
/SGQRCodeExample/Assets.xcassets/wc/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "info" : {
3 | "author" : "xcode",
4 | "version" : 1
5 | }
6 | }
7 |
--------------------------------------------------------------------------------
/SGQRCodeExample/Assets.xcassets/wc/wc_scan_album.imageset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "filename" : "wc_scan_album.png",
5 | "idiom" : "universal",
6 | "scale" : "1x"
7 | },
8 | {
9 | "filename" : "wc_scan_album@2x.png",
10 | "idiom" : "universal",
11 | "scale" : "2x"
12 | },
13 | {
14 | "filename" : "wc_scan_album@3x.png",
15 | "idiom" : "universal",
16 | "scale" : "3x"
17 | }
18 | ],
19 | "info" : {
20 | "author" : "xcode",
21 | "version" : 1
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/SGQRCodeExample/Assets.xcassets/wc/wc_scan_album.imageset/wc_scan_album.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kingsic/SGQRCode/41f0640ba8b1e29576121acab72635a7c9c52d17/SGQRCodeExample/Assets.xcassets/wc/wc_scan_album.imageset/wc_scan_album.png
--------------------------------------------------------------------------------
/SGQRCodeExample/Assets.xcassets/wc/wc_scan_album.imageset/wc_scan_album@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kingsic/SGQRCode/41f0640ba8b1e29576121acab72635a7c9c52d17/SGQRCodeExample/Assets.xcassets/wc/wc_scan_album.imageset/wc_scan_album@2x.png
--------------------------------------------------------------------------------
/SGQRCodeExample/Assets.xcassets/wc/wc_scan_album.imageset/wc_scan_album@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kingsic/SGQRCode/41f0640ba8b1e29576121acab72635a7c9c52d17/SGQRCodeExample/Assets.xcassets/wc/wc_scan_album.imageset/wc_scan_album@3x.png
--------------------------------------------------------------------------------
/SGQRCodeExample/Assets.xcassets/wc/wc_scan_mine_qrcode.imageset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "filename" : "wc_scan_mine_qrcode.png",
5 | "idiom" : "universal",
6 | "scale" : "1x"
7 | },
8 | {
9 | "filename" : "wc_scan_mine_qrcode@2x.png",
10 | "idiom" : "universal",
11 | "scale" : "2x"
12 | },
13 | {
14 | "filename" : "wc_scan_mine_qrcode@3x.png",
15 | "idiom" : "universal",
16 | "scale" : "3x"
17 | }
18 | ],
19 | "info" : {
20 | "author" : "xcode",
21 | "version" : 1
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/SGQRCodeExample/Assets.xcassets/wc/wc_scan_mine_qrcode.imageset/wc_scan_mine_qrcode.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kingsic/SGQRCode/41f0640ba8b1e29576121acab72635a7c9c52d17/SGQRCodeExample/Assets.xcassets/wc/wc_scan_mine_qrcode.imageset/wc_scan_mine_qrcode.png
--------------------------------------------------------------------------------
/SGQRCodeExample/Assets.xcassets/wc/wc_scan_mine_qrcode.imageset/wc_scan_mine_qrcode@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kingsic/SGQRCode/41f0640ba8b1e29576121acab72635a7c9c52d17/SGQRCodeExample/Assets.xcassets/wc/wc_scan_mine_qrcode.imageset/wc_scan_mine_qrcode@2x.png
--------------------------------------------------------------------------------
/SGQRCodeExample/Assets.xcassets/wc/wc_scan_mine_qrcode.imageset/wc_scan_mine_qrcode@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kingsic/SGQRCode/41f0640ba8b1e29576121acab72635a7c9c52d17/SGQRCodeExample/Assets.xcassets/wc/wc_scan_mine_qrcode.imageset/wc_scan_mine_qrcode@3x.png
--------------------------------------------------------------------------------
/SGQRCodeExample/Assets.xcassets/wc/wc_scan_torch.imageset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "filename" : "wc_scan_torch.png",
5 | "idiom" : "universal",
6 | "scale" : "1x"
7 | },
8 | {
9 | "idiom" : "universal",
10 | "scale" : "2x"
11 | },
12 | {
13 | "idiom" : "universal",
14 | "scale" : "3x"
15 | }
16 | ],
17 | "info" : {
18 | "author" : "xcode",
19 | "version" : 1
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/SGQRCodeExample/Assets.xcassets/wc/wc_scan_torch.imageset/wc_scan_torch.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kingsic/SGQRCode/41f0640ba8b1e29576121acab72635a7c9c52d17/SGQRCodeExample/Assets.xcassets/wc/wc_scan_torch.imageset/wc_scan_torch.png
--------------------------------------------------------------------------------
/SGQRCodeExample/Assets.xcassets/wc/wc_scan_torch_hl.imageset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "filename" : "wc_scan_torch_hl.png",
5 | "idiom" : "universal",
6 | "scale" : "1x"
7 | },
8 | {
9 | "idiom" : "universal",
10 | "scale" : "2x"
11 | },
12 | {
13 | "idiom" : "universal",
14 | "scale" : "3x"
15 | }
16 | ],
17 | "info" : {
18 | "author" : "xcode",
19 | "version" : 1
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/SGQRCodeExample/Assets.xcassets/wc/wc_scan_torch_hl.imageset/wc_scan_torch_hl.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kingsic/SGQRCode/41f0640ba8b1e29576121acab72635a7c9c52d17/SGQRCodeExample/Assets.xcassets/wc/wc_scan_torch_hl.imageset/wc_scan_torch_hl.png
--------------------------------------------------------------------------------
/SGQRCodeExample/Base.lproj/LaunchScreen.storyboard:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
--------------------------------------------------------------------------------
/SGQRCodeExample/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | zh_CN
7 | CFBundleExecutable
8 | $(EXECUTABLE_NAME)
9 | CFBundleIdentifier
10 | $(PRODUCT_BUNDLE_IDENTIFIER)
11 | CFBundleInfoDictionaryVersion
12 | 6.0
13 | CFBundleName
14 | SGQRCode
15 | CFBundlePackageType
16 | APPL
17 | CFBundleShortVersionString
18 | 1.0
19 | CFBundleVersion
20 | 1
21 | LSRequiresIPhoneOS
22 |
23 | NSAppTransportSecurity
24 |
25 | NSAllowsArbitraryLoads
26 |
27 |
28 | NSCameraUsageDescription
29 |
30 | NSPhotoLibraryUsageDescription
31 |
32 | UILaunchStoryboardName
33 | LaunchScreen
34 | UIMainStoryboardFile
35 | Main
36 | UIRequiredDeviceCapabilities
37 |
38 | armv7
39 |
40 | UISupportedInterfaceOrientations
41 |
42 | UIInterfaceOrientationPortrait
43 |
44 |
45 |
46 |
--------------------------------------------------------------------------------
/SGQRCodeExample/Main.storyboard:
--------------------------------------------------------------------------------
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 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
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 |
--------------------------------------------------------------------------------
/SGQRCodeExample/MyQRCode/MyQRCodeVC.h:
--------------------------------------------------------------------------------
1 | //
2 | // MyQRCodeVC.h
3 | // SGQRCodeExample
4 | //
5 | // Created by kingsic on 2022/7/9.
6 | // Copyright © 2022 kingsic. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | NS_ASSUME_NONNULL_BEGIN
12 |
13 | @interface MyQRCodeVC : UIViewController
14 |
15 | @end
16 |
17 | NS_ASSUME_NONNULL_END
18 |
--------------------------------------------------------------------------------
/SGQRCodeExample/MyQRCode/MyQRCodeVC.m:
--------------------------------------------------------------------------------
1 | //
2 | // MyQRCodeVC.m
3 | // SGQRCodeExample
4 | //
5 | // Created by kingsic on 2022/7/9.
6 | // Copyright © 2022 kingsic. All rights reserved.
7 | //
8 |
9 | #import "MyQRCodeVC.h"
10 | #import "SGQRCode.h"
11 |
12 | @interface MyQRCodeVC ()
13 | @property (nonatomic, strong) UIImageView *qrcodeImgView;
14 | @property (nonatomic, strong) UIImageView *qrcodeImgView2;
15 | @end
16 |
17 | @implementation MyQRCodeVC
18 |
19 | - (void)viewDidLoad {
20 | [super viewDidLoad];
21 | // Do any additional setup after loading the view.
22 |
23 | self.view.backgroundColor = [UIColor whiteColor];
24 | self.navigationItem.title = @"我的二维码";
25 |
26 | [self.view addSubview:self.qrcodeImgView];
27 | [self.view addSubview:self.qrcodeImgView2];
28 |
29 | NSString *data = @"https://github.com/kingsic";
30 | CGFloat size = self.qrcodeImgView.frame.size.width;
31 |
32 | self.qrcodeImgView.image = [SGGenerateQRCode generateQRCodeWithData:data size:size color:[UIColor redColor] backgroundColor:[UIColor greenColor]];
33 | self.qrcodeImgView2.image = [SGGenerateQRCode generateQRCodeWithData:data size:size logoImage:[UIImage imageNamed:@"bg_image"] ratio:0.25];
34 | }
35 |
36 | - (UIImageView *)qrcodeImgView {
37 | if (!_qrcodeImgView) {
38 | _qrcodeImgView = [[UIImageView alloc] init];
39 | CGFloat w = 200;
40 | CGFloat h = w;
41 | CGFloat x = 0.5 * (self.view.frame.size.width - w);
42 | CGFloat y = 150;
43 | _qrcodeImgView.frame = CGRectMake(x, y, w, h);
44 | }
45 | return _qrcodeImgView;
46 | }
47 |
48 | - (UIImageView *)qrcodeImgView2 {
49 | if (!_qrcodeImgView2) {
50 | _qrcodeImgView2 = [[UIImageView alloc] init];
51 | CGFloat w = 200;
52 | CGFloat h = w;
53 | CGFloat x = 0.5 * (self.view.frame.size.width - w);
54 | CGFloat y = CGRectGetMaxY(_qrcodeImgView.frame) + 50;
55 | _qrcodeImgView2.frame = CGRectMake(x, y, w, h);
56 | }
57 | return _qrcodeImgView2;
58 | }
59 |
60 | /*
61 | #pragma mark - Navigation
62 |
63 | // In a storyboard-based application, you will often want to do a little preparation before navigation
64 | - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
65 | // Get the new view controller using [segue destinationViewController].
66 | // Pass the selected object to the new view controller.
67 | }
68 | */
69 |
70 | @end
71 |
--------------------------------------------------------------------------------
/SGQRCodeExample/QQ/Controller/QQQRCodeVC.h:
--------------------------------------------------------------------------------
1 | //
2 | // QQQRCodeVC.h
3 | // SGQRCodeExample
4 | //
5 | // Created by kingsic on 2022/7/11.
6 | // Copyright © 2022 kingsic. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | NS_ASSUME_NONNULL_BEGIN
12 |
13 | @interface QQQRCodeVC : UIViewController
14 |
15 | @end
16 |
17 | NS_ASSUME_NONNULL_END
18 |
--------------------------------------------------------------------------------
/SGQRCodeExample/QQ/Controller/QQQRCodeVC.m:
--------------------------------------------------------------------------------
1 | //
2 | // QQQRCodeVC.m
3 | // SGQRCodeExample
4 | //
5 | // Created by kingsic on 2022/7/11.
6 | // Copyright © 2022 kingsic. All rights reserved.
7 | //
8 |
9 | #import "QQQRCodeVC.h"
10 | #import "SGQRCode.h"
11 | #import "WebViewController.h"
12 |
13 | @interface QQQRCodeVC () {
14 | SGScanCode *scanCode;
15 | }
16 | @property (nonatomic, strong) SGScanView *scanView;
17 | @property (nonatomic, strong) UILabel *promptLabel;
18 |
19 | @end
20 |
21 | @implementation QQQRCodeVC
22 |
23 | - (void)dealloc {
24 | NSLog(@"QQQRCodeVC - dealloc");
25 |
26 | [self stop];
27 | }
28 |
29 | - (void)start {
30 | [scanCode startRunning];
31 | [self.scanView startScanning];
32 | }
33 |
34 | - (void)stop {
35 | [scanCode stopRunning];
36 | [self.scanView stopScanning];
37 | }
38 |
39 | - (void)viewDidLoad {
40 | [super viewDidLoad];
41 | // Do any additional setup after loading the view from its nib.
42 | self.view.backgroundColor = [UIColor blackColor];
43 |
44 | [self configureNav];
45 |
46 | [self configureUI];
47 |
48 | [self configureQRCode];
49 | }
50 |
51 | - (void)configureUI {
52 | [self.view addSubview:self.scanView];
53 | [self.view addSubview:self.promptLabel];
54 | }
55 |
56 | - (void)configureQRCode {
57 | scanCode = [SGScanCode scanCode];
58 | scanCode.preview = self.view;
59 | scanCode.delegate = self;
60 | [scanCode startRunning];
61 | }
62 |
63 | - (void)scanCode:(SGScanCode *)scanCode result:(NSString *)result {
64 | [self stop];
65 |
66 | [scanCode playSoundEffect:@"SGQRCode.bundle/scan_end_sound.caf"];
67 |
68 | WebViewController *jumpVC = [[WebViewController alloc] init];
69 | jumpVC.comeFromVC = ComeFromWC;
70 | [self.navigationController pushViewController:jumpVC animated:YES];
71 |
72 | if ([result hasPrefix:@"http"]) {
73 | jumpVC.jump_URL = result;
74 | } else {
75 | jumpVC.jump_bar_code = result;
76 | }
77 | }
78 |
79 | - (void)configureNav {
80 | self.navigationItem.title = @"扫一扫";
81 | self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"相册" style:(UIBarButtonItemStyleDone) target:self action:@selector(rightBarButtonItenAction)];
82 | }
83 |
84 | - (void)rightBarButtonItenAction {
85 | [SGPermission permissionWithType:SGPermissionTypePhoto completion:^(SGPermission * _Nonnull permission, SGPermissionStatus status) {
86 | if (status == SGPermissionStatusNotDetermined) {
87 | [permission request:^(BOOL granted) {
88 | if (granted) {
89 | NSLog(@"第一次授权成功");
90 | [self _enterImagePickerController];
91 | } else {
92 | NSLog(@"第一次授权失败");
93 | }
94 | }];
95 | } else if (status == SGPermissionStatusAuthorized) {
96 | NSLog(@"SGPermissionStatusAuthorized");
97 | [self _enterImagePickerController];
98 | } else if (status == SGPermissionStatusDenied) {
99 | NSLog(@"SGPermissionStatusDenied");
100 | NSDictionary *infoDict = [[NSBundle mainBundle] infoDictionary];
101 | NSString *app_Name = [infoDict objectForKey:@"CFBundleDisplayName"];
102 | if (app_Name == nil) {
103 | app_Name = [infoDict objectForKey:@"CFBundleName"];
104 | }
105 |
106 | NSString *messageString = [NSString stringWithFormat:@"[前往:设置 - 隐私 - 照片 - %@] 允许应用访问", app_Name];
107 | UIAlertController *alertC = [UIAlertController alertControllerWithTitle:@"温馨提示" message:messageString preferredStyle:(UIAlertControllerStyleAlert)];
108 | UIAlertAction *alertA = [UIAlertAction actionWithTitle:@"确定" style:(UIAlertActionStyleDefault) handler:nil];
109 |
110 | [alertC addAction:alertA];
111 | [self presentViewController:alertC animated:YES completion:nil];
112 | } else if (status == SGPermissionStatusRestricted) {
113 | NSLog(@"SGPermissionStatusRestricted");
114 | UIAlertController *alertC = [UIAlertController alertControllerWithTitle:@"温馨提示" message:@"由于系统原因, 无法访问相册" preferredStyle:(UIAlertControllerStyleAlert)];
115 | UIAlertAction *alertA = [UIAlertAction actionWithTitle:@"确定" style:(UIAlertActionStyleDefault) handler:nil];
116 | [alertC addAction:alertA];
117 | [self presentViewController:alertC animated:YES completion:nil];
118 | }
119 | }];
120 | }
121 |
122 | - (void)_enterImagePickerController {
123 | [self stop];
124 |
125 | UIImagePickerController *imagePicker = [[UIImagePickerController alloc] init];
126 | imagePicker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
127 | imagePicker.delegate = self;
128 | imagePicker.modalPresentationStyle = UIModalPresentationCustom;
129 | [self presentViewController:imagePicker animated:YES completion:nil];
130 | }
131 |
132 | #pragma mark - - UIImagePickerControllerDelegate 的方法
133 | - (void)imagePickerControllerDidCancel:(UIImagePickerController *)picker {
134 | [self dismissViewControllerAnimated:YES completion:nil];
135 | [self start];
136 | }
137 |
138 | - (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {
139 | UIImage *image = [info objectForKey:UIImagePickerControllerOriginalImage];
140 | [scanCode readQRCode:image completion:^(NSString *result) {
141 | if (result == nil) {
142 | [self dismissViewControllerAnimated:YES completion:nil];
143 | [self start];
144 | NSLog(@"未识别出二维码");
145 | } else {
146 | [self dismissViewControllerAnimated:YES completion:^{
147 | WebViewController *jumpVC = [[WebViewController alloc] init];
148 | jumpVC.comeFromVC = ComeFromWC;
149 | [self.navigationController pushViewController:jumpVC animated:YES];
150 |
151 | if ([result hasPrefix:@"http"]) {
152 | jumpVC.jump_URL = result;
153 | } else {
154 | jumpVC.jump_bar_code = result;
155 | }
156 | }];
157 | }
158 | }];
159 | }
160 |
161 | - (SGScanView *)scanView {
162 | if (!_scanView) {
163 | SGScanViewConfigure *configure = [[SGScanViewConfigure alloc] init];
164 | configure.isShowBorder = YES;
165 | configure.borderColor = [UIColor clearColor];
166 | configure.cornerColor = [UIColor whiteColor];
167 | configure.cornerWidth = 3;
168 | configure.cornerLength = 15;
169 | configure.isFromTop = YES;
170 | configure.scanline = @"SGQRCode.bundle/scan_scanline_qq";
171 | configure.color = [UIColor clearColor];
172 |
173 | CGFloat x = 0;
174 | CGFloat y = 0;
175 | CGFloat w = self.view.frame.size.width;
176 | CGFloat h = self.view.frame.size.height;
177 | _scanView = [[SGScanView alloc] initWithFrame:CGRectMake(x, y, w, h) configure:configure];
178 | [_scanView startScanning];
179 | _scanView.scanFrame = CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height);
180 | }
181 | return _scanView;
182 | }
183 |
184 | - (UILabel *)promptLabel {
185 | if (!_promptLabel) {
186 | _promptLabel = [[UILabel alloc] init];
187 | _promptLabel.backgroundColor = [UIColor clearColor];
188 | CGFloat promptLabelX = 0;
189 | CGFloat promptLabelY = 0.73 * self.view.frame.size.height;
190 | CGFloat promptLabelW = self.view.frame.size.width;
191 | CGFloat promptLabelH = 25;
192 | _promptLabel.frame = CGRectMake(promptLabelX, promptLabelY, promptLabelW, promptLabelH);
193 | _promptLabel.textAlignment = NSTextAlignmentCenter;
194 | _promptLabel.font = [UIFont boldSystemFontOfSize:13.0];
195 | _promptLabel.textColor = [[UIColor whiteColor] colorWithAlphaComponent:0.6];
196 | _promptLabel.text = @"将二维码/条码放入框内, 即可自动扫描";
197 | }
198 | return _promptLabel;
199 | }
200 |
201 |
202 | @end
203 |
--------------------------------------------------------------------------------
/SGQRCodeExample/ViewController.h:
--------------------------------------------------------------------------------
1 | //
2 | // ViewController.h
3 | // SGQRCodeExample
4 | //
5 | // Created by kingsic on 16/8/25.
6 | // Copyright © 2016年 kingsic. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface ViewController : UIViewController
12 |
13 | @end
14 |
--------------------------------------------------------------------------------
/SGQRCodeExample/ViewController.m:
--------------------------------------------------------------------------------
1 | //
2 | // ViewController.m
3 | // SGQRCodeExample
4 | //
5 | // Created by kingsic on 16/8/25.
6 | // Copyright © 2016年 kingsic. All rights reserved.
7 | //
8 |
9 | #import "ViewController.h"
10 | #import "SGQRCode.h"
11 | #import "WCQRCodeVC.h"
12 | #import "WBQRCodeVC.h"
13 | #import "QQQRCodeVC.h"
14 | #import "XCQRCodeVC.h"
15 |
16 | @interface ViewController ()
17 | @property (weak, nonatomic) IBOutlet UITableView *tableView;
18 | @property (nonatomic, strong) NSArray *dataList;
19 | @end
20 |
21 | @implementation ViewController
22 |
23 | - (void)viewDidLoad {
24 | [super viewDidLoad];
25 |
26 | [self configTableView];
27 | }
28 |
29 | - (void)configTableView {
30 | _dataList = @[@"微信", @"QQ", @"携程", @"原微博"];
31 | [_tableView registerClass:[UITableViewCell class] forCellReuseIdentifier:@"cell"];
32 | _tableView.tableFooterView = [[UIView alloc] initWithFrame:CGRectZero];
33 | }
34 |
35 | - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
36 | return _dataList.count;
37 | }
38 |
39 | - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
40 | UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell"];
41 | cell.textLabel.text = _dataList[indexPath.row];
42 | cell.backgroundColor = [UIColor clearColor];
43 | cell.selectionStyle = UITableViewCellSelectionStyleNone;
44 | cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
45 | return cell;
46 | }
47 |
48 | - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
49 |
50 | [SGPermission permissionWithType:SGPermissionTypeCamera completion:^(SGPermission * _Nonnull permission, SGPermissionStatus status) {
51 | if (status == SGPermissionStatusNotDetermined) {
52 | [permission request:^(BOOL granted) {
53 | if (granted) {
54 | NSLog(@"第一次授权成功");
55 | UIViewController *VC;
56 | if (indexPath.row == 0) {
57 | VC = [[WCQRCodeVC alloc] init];
58 | } else if (indexPath.row == 1) {
59 | VC = [[QQQRCodeVC alloc] init];
60 | } else if (indexPath.row == 2) {
61 | VC = [[XCQRCodeVC alloc] init];
62 | } else if (indexPath.row == 3) {
63 | VC = [[WBQRCodeVC alloc] init];
64 | }
65 | [self.navigationController pushViewController:VC animated:YES];
66 |
67 | } else {
68 | NSLog(@"第一次授权失败");
69 | }
70 | }];
71 | } else if (status == SGPermissionStatusAuthorized) {
72 | NSLog(@"SGPermissionStatusAuthorized");
73 | UIViewController *VC;
74 | if (indexPath.row == 0) {
75 | VC = [[WCQRCodeVC alloc] init];
76 | } else if (indexPath.row == 1) {
77 | VC = [[QQQRCodeVC alloc] init];
78 | } else if (indexPath.row == 2) {
79 | VC = [[XCQRCodeVC alloc] init];
80 | } else if (indexPath.row == 3) {
81 | VC = [[WBQRCodeVC alloc] init];
82 | }
83 | [self.navigationController pushViewController:VC animated:YES];
84 |
85 | } else if (status == SGPermissionStatusDenied) {
86 | NSLog(@"SGPermissionStatusDenied");
87 | [self failed];
88 | } else if (status == SGPermissionStatusRestricted) {
89 | NSLog(@"SGPermissionStatusRestricted");
90 | [self unknown];
91 | }
92 |
93 | }];
94 |
95 | }
96 |
97 | - (void)failed {
98 | UIAlertController *alertC = [UIAlertController alertControllerWithTitle:@"温馨提示" message:@"[前往:设置 - 隐私 - 相机 - SGQRCode] 打开访问开关" preferredStyle:(UIAlertControllerStyleAlert)];
99 | UIAlertAction *alertA = [UIAlertAction actionWithTitle:@"确定" style:(UIAlertActionStyleDefault) handler:^(UIAlertAction * _Nonnull action) {
100 | }];
101 |
102 | [alertC addAction:alertA];
103 | dispatch_async(dispatch_get_main_queue(), ^{
104 | [self presentViewController:alertC animated:YES completion:nil];
105 | });
106 | }
107 |
108 | - (void)unknown {
109 | UIAlertController *alertC = [UIAlertController alertControllerWithTitle:@"温馨提示" message:@"未检测到您的摄像头" preferredStyle:(UIAlertControllerStyleAlert)];
110 | UIAlertAction *alertA = [UIAlertAction actionWithTitle:@"确定" style:(UIAlertActionStyleDefault) handler:^(UIAlertAction * _Nonnull action) {
111 |
112 | }];
113 |
114 | [alertC addAction:alertA];
115 | dispatch_async(dispatch_get_main_queue(), ^{
116 | [self presentViewController:alertC animated:YES completion:nil];
117 | });
118 | }
119 |
120 |
121 | @end
122 |
--------------------------------------------------------------------------------
/SGQRCodeExample/WB/Controller/WBQRCodeVC.h:
--------------------------------------------------------------------------------
1 | //
2 | // WBQRCodeVC.h
3 | // SGQRCodeExample
4 | //
5 | // Created by kingsic on 2018/2/8.
6 | // Copyright © 2018年 kingsic. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface WBQRCodeVC : UIViewController
12 |
13 | @end
14 |
--------------------------------------------------------------------------------
/SGQRCodeExample/WB/Controller/WBQRCodeVC.m:
--------------------------------------------------------------------------------
1 | //
2 | // WBQRCodeVC.m
3 | // SGQRCodeExample
4 | //
5 | // Created by kingsic on 2018/2/8.
6 | // Copyright © 2018年 kingsic. All rights reserved.
7 | //
8 |
9 | #import "WBQRCodeVC.h"
10 | #import "SGQRCode.h"
11 | #import "WebViewController.h"
12 |
13 | @interface WBQRCodeVC () {
14 | SGScanCode *scanCode;
15 | }
16 | @property (nonatomic, strong) SGScanView *scanView;
17 | @property (nonatomic, strong) UILabel *promptLabel;
18 |
19 | @end
20 |
21 | @implementation WBQRCodeVC
22 |
23 | - (void)dealloc {
24 | NSLog(@"WBQRCodeVC - dealloc");
25 |
26 | [self stop];
27 | }
28 |
29 | - (void)start {
30 | [scanCode startRunning];
31 | [self.scanView startScanning];
32 | }
33 |
34 | - (void)stop {
35 | [scanCode stopRunning];
36 | [self.scanView stopScanning];
37 | }
38 |
39 | - (void)viewWillAppear:(BOOL)animated {
40 | [super viewWillAppear:animated];
41 |
42 | [self start];
43 | }
44 |
45 | - (void)viewDidLoad {
46 | [super viewDidLoad];
47 | // Do any additional setup after loading the view from its nib.
48 | self.view.backgroundColor = [UIColor blackColor];
49 |
50 | [self configureNav];
51 |
52 | [self configureUI];
53 |
54 | [self configureQRCode];
55 | }
56 |
57 | - (void)configureUI {
58 | [self.view addSubview:self.scanView];
59 | [self.view addSubview:self.promptLabel];
60 | }
61 |
62 | - (void)configureQRCode {
63 | scanCode = [SGScanCode scanCode];
64 | scanCode.preview = self.view;
65 | scanCode.delegate = self;
66 | CGFloat w = 0.7;
67 | CGFloat x = 0.5 * (1 - w);
68 | CGFloat h = (self.view.frame.size.width / self.view.frame.size.height) * w;
69 | CGFloat y = 0.5 * (1 - h);
70 | /// 扫描范围。对应辅助扫描框的frame(borderFrame)设置
71 | scanCode.rectOfInterest = CGRectMake(y, x, h, w);
72 | }
73 |
74 | - (void)scanCode:(SGScanCode *)scanCode result:(NSString *)result {
75 | [self stop];
76 |
77 | [scanCode playSoundEffect:@"SGQRCode.bundle/scan_end_sound.caf"];
78 |
79 | WebViewController *jumpVC = [[WebViewController alloc] init];
80 | jumpVC.comeFromVC = ComeFromWB;
81 | [self.navigationController pushViewController:jumpVC animated:YES];
82 |
83 | if ([result hasPrefix:@"http"]) {
84 | jumpVC.jump_URL = result;
85 | } else {
86 | jumpVC.jump_bar_code = result;
87 | }
88 | }
89 |
90 | - (void)configureNav {
91 | self.navigationItem.title = @"扫一扫";
92 | self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"相册" style:(UIBarButtonItemStyleDone) target:self action:@selector(rightBarButtonItenAction)];
93 | }
94 |
95 | - (void)rightBarButtonItenAction {
96 | [SGPermission permissionWithType:SGPermissionTypePhoto completion:^(SGPermission * _Nonnull permission, SGPermissionStatus status) {
97 | if (status == SGPermissionStatusNotDetermined) {
98 | [permission request:^(BOOL granted) {
99 | if (granted) {
100 | NSLog(@"第一次授权成功");
101 | [self _enterImagePickerController];
102 | } else {
103 | NSLog(@"第一次授权失败");
104 | }
105 | }];
106 | } else if (status == SGPermissionStatusAuthorized) {
107 | NSLog(@"SGPermissionStatusAuthorized");
108 | [self _enterImagePickerController];
109 | } else if (status == SGPermissionStatusDenied) {
110 | NSLog(@"SGPermissionStatusDenied");
111 | NSDictionary *infoDict = [[NSBundle mainBundle] infoDictionary];
112 | NSString *app_Name = [infoDict objectForKey:@"CFBundleDisplayName"];
113 | if (app_Name == nil) {
114 | app_Name = [infoDict objectForKey:@"CFBundleName"];
115 | }
116 |
117 | NSString *messageString = [NSString stringWithFormat:@"[前往:设置 - 隐私 - 照片 - %@] 允许应用访问", app_Name];
118 | UIAlertController *alertC = [UIAlertController alertControllerWithTitle:@"温馨提示" message:messageString preferredStyle:(UIAlertControllerStyleAlert)];
119 | UIAlertAction *alertA = [UIAlertAction actionWithTitle:@"确定" style:(UIAlertActionStyleDefault) handler:nil];
120 |
121 | [alertC addAction:alertA];
122 | [self presentViewController:alertC animated:YES completion:nil];
123 | } else if (status == SGPermissionStatusRestricted) {
124 | NSLog(@"SGPermissionStatusRestricted");
125 | UIAlertController *alertC = [UIAlertController alertControllerWithTitle:@"温馨提示" message:@"由于系统原因, 无法访问相册" preferredStyle:(UIAlertControllerStyleAlert)];
126 | UIAlertAction *alertA = [UIAlertAction actionWithTitle:@"确定" style:(UIAlertActionStyleDefault) handler:nil];
127 | [alertC addAction:alertA];
128 | [self presentViewController:alertC animated:YES completion:nil];
129 | }
130 | }];
131 | }
132 |
133 | - (void)_enterImagePickerController {
134 | [self stop];
135 |
136 | UIImagePickerController *imagePicker = [[UIImagePickerController alloc] init];
137 | imagePicker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
138 | imagePicker.delegate = self;
139 | imagePicker.modalPresentationStyle = UIModalPresentationCustom;
140 | [self presentViewController:imagePicker animated:YES completion:nil];
141 | }
142 |
143 | #pragma mark - - UIImagePickerControllerDelegate 的方法
144 | - (void)imagePickerControllerDidCancel:(UIImagePickerController *)picker {
145 | [self dismissViewControllerAnimated:YES completion:nil];
146 | [self start];
147 | }
148 |
149 | - (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {
150 | UIImage *image = [info objectForKey:UIImagePickerControllerOriginalImage];
151 | [scanCode readQRCode:image completion:^(NSString *result) {
152 | if (result == nil) {
153 | [self dismissViewControllerAnimated:YES completion:nil];
154 | [self start];
155 | NSLog(@"未识别出二维码");
156 | } else {
157 | [self dismissViewControllerAnimated:YES completion:^{
158 | WebViewController *jumpVC = [[WebViewController alloc] init];
159 | jumpVC.comeFromVC = ComeFromWB;
160 | [self.navigationController pushViewController:jumpVC animated:YES];
161 |
162 | if ([result hasPrefix:@"http"]) {
163 | jumpVC.jump_URL = result;
164 | } else {
165 | jumpVC.jump_bar_code = result;
166 | }
167 | }];
168 | }
169 | }];
170 | }
171 |
172 | - (SGScanView *)scanView {
173 | if (!_scanView) {
174 | SGScanViewConfigure *configure = [[SGScanViewConfigure alloc] init];
175 | configure.cornerColor = [UIColor orangeColor];
176 | configure.isFromTop = YES;
177 | // 打开辅助扫描框
178 | configure.isShowBorder = YES;
179 | configure.scanlineStep = 3;
180 | configure.scanline = @"SGQRCode.bundle/scan_scanline_wb";
181 |
182 | CGFloat x = 0;
183 | CGFloat y = 0;
184 | CGFloat w = self.view.frame.size.width;
185 | CGFloat h = self.view.frame.size.height;
186 | _scanView = [[SGScanView alloc] initWithFrame:CGRectMake(x, y, w, h) configure:configure];
187 | }
188 | return _scanView;
189 | }
190 |
191 | - (UILabel *)promptLabel {
192 | if (!_promptLabel) {
193 | _promptLabel = [[UILabel alloc] init];
194 | _promptLabel.backgroundColor = [UIColor clearColor];
195 | CGFloat promptLabelX = 0;
196 | CGFloat promptLabelY = 0.73 * self.view.frame.size.height;
197 | CGFloat promptLabelW = self.view.frame.size.width;
198 | CGFloat promptLabelH = 25;
199 | _promptLabel.frame = CGRectMake(promptLabelX, promptLabelY, promptLabelW, promptLabelH);
200 | _promptLabel.textAlignment = NSTextAlignmentCenter;
201 | _promptLabel.font = [UIFont boldSystemFontOfSize:13.0];
202 | _promptLabel.textColor = [[UIColor whiteColor] colorWithAlphaComponent:0.6];
203 | _promptLabel.text = @"将二维码/条码放入框内, 即可自动扫描";
204 | }
205 | return _promptLabel;
206 | }
207 |
208 | @end
209 |
--------------------------------------------------------------------------------
/SGQRCodeExample/WC/Controller/WCQRCodeVC.h:
--------------------------------------------------------------------------------
1 | //
2 | // WCQRCodeVC.h
3 | // SGQRCodeExample
4 | //
5 | // Created by kingsic on 17/3/20.
6 | // Copyright © 2017年 kingsic. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface WCQRCodeVC : UIViewController
12 |
13 | @end
14 |
--------------------------------------------------------------------------------
/SGQRCodeExample/WC/Controller/WCQRCodeVC.m:
--------------------------------------------------------------------------------
1 | //
2 | // WCQRCodeVC.m
3 | // SGQRCodeExample
4 | //
5 | // Created by kingsic on 17/3/20.
6 | // Copyright © 2017年 kingsic. All rights reserved.
7 | //
8 |
9 | #import "WCQRCodeVC.h"
10 | #import "SGQRCode.h"
11 | #import "WCToolBar.h"
12 | #import "MyQRCodeVC.h"
13 | #import "WebViewController.h"
14 |
15 | @interface WCQRCodeVC ()
16 | {
17 | SGScanCode *scanCode;
18 | }
19 | @property (nonatomic, strong) SGScanView *scanView;
20 | @property (nonatomic, strong) UIView *bottomView;
21 | @property (nonatomic, strong) WCToolBar *toolBar;
22 | @end
23 |
24 | @implementation WCQRCodeVC
25 |
26 | - (void)dealloc {
27 | NSLog(@"WCQRCodeVC - dealloc");
28 |
29 | [self stop];
30 | }
31 |
32 | - (void)viewWillAppear:(BOOL)animated {
33 | [super viewWillAppear:animated];
34 |
35 | [self start];
36 | }
37 |
38 | - (void)viewWillDisappear:(BOOL)animated {
39 | [super viewWillDisappear:animated];
40 |
41 | [self stop];
42 | }
43 |
44 | - (void)start {
45 | [scanCode startRunning];
46 | [self.scanView startScanning];
47 | }
48 |
49 | - (void)stop {
50 | [scanCode stopRunning];
51 | [self.scanView stopScanning];
52 | }
53 |
54 | - (void)viewDidLoad {
55 | [super viewDidLoad];
56 | // Do any additional setup after loading the view from its nib.
57 |
58 | [self configUI];
59 |
60 | [self configScanCode];
61 | }
62 |
63 | - (void)configUI {
64 | [self.view addSubview:self.scanView];
65 |
66 | [self.view addSubview:self.bottomView];
67 |
68 | [self.view addSubview:self.toolBar];
69 | }
70 |
71 | - (void)configScanCode {
72 | scanCode = [[SGScanCode alloc] init];
73 | if (![scanCode checkCameraDeviceRearAvailable]) {
74 | return;;
75 | }
76 | scanCode.delegate = self;
77 | scanCode.sampleBufferDelegate = self;
78 | scanCode.preview = self.view;
79 | }
80 |
81 | - (void)scanCode:(SGScanCode *)scanCode result:(NSString *)result {
82 | [self stop];
83 |
84 | [scanCode playSoundEffect:@"SGQRCode.bundle/scan_end_sound.caf"];
85 |
86 | WebViewController *jumpVC = [[WebViewController alloc] init];
87 | jumpVC.comeFromVC = ComeFromWC;
88 | [self.navigationController pushViewController:jumpVC animated:YES];
89 |
90 | if ([result hasPrefix:@"http"]) {
91 | jumpVC.jump_URL = result;
92 | } else {
93 | jumpVC.jump_bar_code = result;
94 | }
95 | }
96 |
97 | - (void)scanCode:(SGScanCode *)scanCode brightness:(CGFloat)brightness {
98 | if (brightness < - 1.5) {
99 | [self.toolBar showTorch];
100 | }
101 |
102 | if (brightness > 0) {
103 | [self.toolBar dismissTorch];
104 | }
105 | }
106 |
107 | - (SGScanView *)scanView {
108 | if (!_scanView) {
109 | SGScanViewConfigure *configure = [[SGScanViewConfigure alloc] init];
110 |
111 | CGFloat x = 0;
112 | CGFloat y = 0;
113 | CGFloat w = self.view.frame.size.width;
114 | CGFloat h = self.view.frame.size.height;
115 | _scanView = [[SGScanView alloc] initWithFrame:CGRectMake(x, y, w, h) configure:configure];
116 |
117 | CGFloat scan_x = 0;
118 | CGFloat scan_y = 0.18 * self.view.frame.size.height;
119 | CGFloat scan_w = self.view.frame.size.width - 2 * x;
120 | CGFloat scan_h = self.view.frame.size.height - 2.55 * scan_y;
121 | _scanView.scanFrame = CGRectMake(scan_x, scan_y, scan_w, scan_h);
122 |
123 | __weak typeof(self) weakSelf = self;
124 | _scanView.doubleTapBlock = ^(BOOL selected) {
125 | __strong typeof(weakSelf) strongSelf = weakSelf;
126 |
127 | if (selected) {
128 | [strongSelf->scanCode setVideoZoomFactor:4.0];
129 | } else {
130 | [strongSelf->scanCode setVideoZoomFactor:1.0];
131 | }
132 | };
133 | }
134 | return _scanView;
135 | }
136 |
137 | - (WCToolBar *)toolBar {
138 | if (!_toolBar) {
139 | _toolBar = [(WCToolBar *)[WCToolBar alloc] init];
140 | CGFloat h = 220;
141 | CGFloat y = CGRectGetMinY(self.bottomView.frame) - h;
142 | _toolBar.frame = CGRectMake(0, y, self.view.frame.size.width, h);
143 | [_toolBar addQRCodeTarget:self action:@selector(qrcode_action)];
144 | [_toolBar addAlbumTarget:self action:@selector(album_action)];
145 | }
146 | return _toolBar;
147 | }
148 |
149 | - (void)qrcode_action {
150 | [self stop];
151 |
152 | MyQRCodeVC *vc = [[MyQRCodeVC alloc] init];
153 | [self.navigationController pushViewController:vc animated:YES];
154 | }
155 |
156 | - (void)album_action {
157 | [SGPermission permissionWithType:SGPermissionTypePhoto completion:^(SGPermission * _Nonnull permission, SGPermissionStatus status) {
158 | if (status == SGPermissionStatusNotDetermined) {
159 | [permission request:^(BOOL granted) {
160 | if (granted) {
161 | NSLog(@"第一次授权成功");
162 | [self _enterImagePickerController];
163 | } else {
164 | NSLog(@"第一次授权失败");
165 | }
166 | }];
167 | } else if (status == SGPermissionStatusAuthorized) {
168 | [self _enterImagePickerController];
169 | } else if (status == SGPermissionStatusDenied) {
170 | NSLog(@"SGPermissionStatusDenied");
171 | NSDictionary *infoDict = [[NSBundle mainBundle] infoDictionary];
172 | NSString *app_Name = [infoDict objectForKey:@"CFBundleDisplayName"];
173 | if (app_Name == nil) {
174 | app_Name = [infoDict objectForKey:@"CFBundleName"];
175 | }
176 |
177 | NSString *messageString = [NSString stringWithFormat:@"[前往:设置 - 隐私 - 照片 - %@] 允许应用访问", app_Name];
178 | UIAlertController *alertC = [UIAlertController alertControllerWithTitle:@"温馨提示" message:messageString preferredStyle:(UIAlertControllerStyleAlert)];
179 | UIAlertAction *alertA = [UIAlertAction actionWithTitle:@"确定" style:(UIAlertActionStyleDefault) handler:nil];
180 |
181 | [alertC addAction:alertA];
182 | [self presentViewController:alertC animated:YES completion:nil];
183 | } else if (status == SGPermissionStatusRestricted) {
184 | NSLog(@"SGPermissionStatusRestricted");
185 | UIAlertController *alertC = [UIAlertController alertControllerWithTitle:@"温馨提示" message:@"由于系统原因, 无法访问相册" preferredStyle:(UIAlertControllerStyleAlert)];
186 | UIAlertAction *alertA = [UIAlertAction actionWithTitle:@"确定" style:(UIAlertActionStyleDefault) handler:nil];
187 | [alertC addAction:alertA];
188 | [self presentViewController:alertC animated:YES completion:nil];
189 | }
190 | }];
191 | }
192 |
193 | - (void)_enterImagePickerController {
194 | [self stop];
195 |
196 | UIImagePickerController *imagePicker = [[UIImagePickerController alloc] init];
197 | imagePicker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
198 | imagePicker.delegate = self;
199 | imagePicker.modalPresentationStyle = UIModalPresentationCustom;
200 | [self presentViewController:imagePicker animated:YES completion:nil];
201 | }
202 |
203 | #pragma mark - - UIImagePickerControllerDelegate 的方法
204 | - (void)imagePickerControllerDidCancel:(UIImagePickerController *)picker {
205 | [self dismissViewControllerAnimated:YES completion:nil];
206 |
207 | [self start];
208 | }
209 |
210 | - (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {
211 | UIImage *image = [info objectForKey:UIImagePickerControllerOriginalImage];
212 |
213 | [scanCode readQRCode:image completion:^(NSString *result) {
214 | if (result == nil) {
215 | [self dismissViewControllerAnimated:YES completion:nil];
216 | [self start];
217 | } else {
218 | [self->scanCode playSoundEffect:@"SGQRCode.bundle/scan_end_sound.caf"];
219 |
220 | [self dismissViewControllerAnimated:YES completion:^{
221 | WebViewController *jumpVC = [[WebViewController alloc] init];
222 | jumpVC.comeFromVC = ComeFromWC;
223 | [self.navigationController pushViewController:jumpVC animated:YES];
224 |
225 | if ([result hasPrefix:@"http"]) {
226 | jumpVC.jump_URL = result;
227 | } else {
228 | jumpVC.jump_bar_code = result;
229 | }
230 | }];
231 | }
232 | }];
233 | }
234 |
235 | - (UIView *)bottomView {
236 | if (!_bottomView) {
237 | _bottomView = [[UIView alloc] init];
238 | CGFloat h = 100;
239 | CGFloat x = 0;
240 | CGFloat y = self.view.frame.size.height - h;
241 | CGFloat w = self.view.frame.size.width;
242 | _bottomView.frame = CGRectMake(x, y, w, h);
243 | _bottomView.backgroundColor = [UIColor blackColor];
244 |
245 | UILabel *lab = [[UILabel alloc] init];
246 | lab.text = @"扫一扫";
247 | lab.textAlignment = NSTextAlignmentCenter;
248 | lab.textColor = [UIColor whiteColor];
249 | lab.frame = CGRectMake(0, 0, w, h - 34);
250 | [_bottomView addSubview:lab];
251 | }
252 | return _bottomView;
253 | }
254 |
255 | @end
256 |
--------------------------------------------------------------------------------
/SGQRCodeExample/WC/View/WCToolBar.h:
--------------------------------------------------------------------------------
1 | //
2 | // WCToolBar.h
3 | // SGQRCodeExample
4 | //
5 | // Created by kingsic on 2022/7/9.
6 | // Copyright © 2022 kingsic. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | NS_ASSUME_NONNULL_BEGIN
12 |
13 | @interface WCToolBar : UIView
14 | - (void)addQRCodeTarget:(id)aTarget action:(SEL)aAction;
15 | - (void)addAlbumTarget:(id)aTarget action:(SEL)aAction;
16 |
17 | - (void)showTorch;
18 | - (void)dismissTorch;
19 | @end
20 |
21 | NS_ASSUME_NONNULL_END
22 |
--------------------------------------------------------------------------------
/SGQRCodeExample/WC/View/WCToolBar.m:
--------------------------------------------------------------------------------
1 | //
2 | // WCToolBar.m
3 | // SGQRCodeExample
4 | //
5 | // Created by kingsic on 2022/7/9.
6 | // Copyright © 2022 kingsic. All rights reserved.
7 | //
8 |
9 | #import "WCToolBar.h"
10 | #import "SGQRCode.h"
11 |
12 | @interface WCToolBar ()
13 | @property (nonatomic, strong) UIButton *torchBtn;
14 | @property (nonatomic, strong) UILabel *torchLab;
15 | @property (nonatomic, strong) UILabel *tipsLab;
16 | @property (nonatomic, strong) UIImageView *qrcodeImgView;
17 | @property (nonatomic, strong) UILabel *qrcodeLab;
18 | @property (nonatomic, strong) UIImageView *albumImgView;
19 | @property (nonatomic, strong) UILabel *albumLab;
20 | @end
21 |
22 | @implementation WCToolBar
23 |
24 | - (instancetype)initWithFrame:(CGRect)frame {
25 | if (self = [super initWithFrame:frame]) {
26 |
27 | [self addSubview:self.torchBtn];
28 |
29 | [self addSubview:self.torchLab];
30 |
31 | [self addSubview:self.tipsLab];
32 |
33 | [self addSubview:self.qrcodeImgView];
34 |
35 | [self addSubview:self.qrcodeLab];
36 |
37 | [self addSubview:self.albumImgView];
38 |
39 | [self addSubview:self.albumLab];
40 | }
41 | return self;
42 | }
43 |
44 | - (void)layoutSubviews {
45 | [super layoutSubviews];
46 |
47 | CGFloat tBtn_w = 50;
48 | CGFloat tBtn_h = 70;
49 | CGFloat tBtn_x = 0.5 * (self.frame.size.width - tBtn_w);
50 | CGFloat tBtn_y = 0;
51 | self.torchBtn.frame = CGRectMake(tBtn_x, tBtn_y, tBtn_w, tBtn_h);
52 |
53 | CGFloat tLab_w = self.frame.size.width;
54 | CGFloat tLab_h = 12;
55 | CGFloat tLab_x = 0;
56 | CGFloat tLab_y = CGRectGetMaxY(self.torchBtn.frame) + 5;
57 | self.torchLab.frame = CGRectMake(tLab_x, tLab_y, tLab_w, tLab_h);
58 |
59 | CGFloat tipsLab_w = self.frame.size.width;
60 | CGFloat tipsLab_h = 15;
61 | CGFloat tipsLab_x = 0;
62 | CGFloat tipsLab_y = CGRectGetMaxY(self.torchLab.frame) + 10;
63 | self.tipsLab.frame = CGRectMake(tipsLab_x, tipsLab_y, tipsLab_w, tipsLab_h);
64 |
65 | CGFloat qrLab_w = 100;
66 | CGFloat qrLab_h = 12;
67 | CGFloat qrLab_x = 0;
68 | CGFloat qrLab_y = self.frame.size.height - qrLab_h - 20;
69 | self.qrcodeLab.frame = CGRectMake(qrLab_x, qrLab_y, qrLab_w, qrLab_h);
70 |
71 | CGFloat qrImgView_w = 50;
72 | CGFloat qrImgView_h = 50;
73 | CGFloat qrImgView_x = 0.5 * (qrLab_w - qrImgView_w);
74 | CGFloat qrImgView_y = CGRectGetMinY(self.qrcodeLab.frame) - qrImgView_h - 9;
75 | self.qrcodeImgView.frame = CGRectMake(qrImgView_x, qrImgView_y, qrImgView_w, qrImgView_h);
76 |
77 | CGFloat alLab_w = qrLab_w;
78 | CGFloat alLab_h = qrLab_h;
79 | CGFloat alLab_x = self.frame.size.width - alLab_w;
80 | CGFloat alLab_y = qrLab_y;
81 | self.albumLab.frame = CGRectMake(alLab_x, alLab_y, alLab_w, alLab_h);
82 |
83 | CGFloat alImgView_w = qrImgView_w;
84 | CGFloat alImgView_h = qrImgView_h;
85 | CGFloat alImgView_x = self.frame.size.width - alImgView_w - 0.5 * (qrLab_w - alImgView_w);
86 | CGFloat alImgView_y = qrImgView_y;
87 | self.albumImgView.frame = CGRectMake(alImgView_x, alImgView_y, alImgView_w, alImgView_h);
88 |
89 | self.qrcodeImgView.layer.cornerRadius = 0.5 * qrImgView_w;
90 | self.albumImgView.layer.cornerRadius = 0.5 * qrImgView_w;
91 | }
92 |
93 | - (UIButton *)torchBtn {
94 | if (!_torchBtn) {
95 | _torchBtn = [UIButton buttonWithType:UIButtonTypeCustom];
96 | [_torchBtn setBackgroundImage:[UIImage imageNamed:@"wc_scan_torch"] forState:(UIControlStateNormal)];
97 | [_torchBtn addTarget:self action:@selector(torchBtn_action:) forControlEvents:(UIControlEventTouchUpInside)];
98 | _torchBtn.hidden = YES;
99 | }
100 | return _torchBtn;
101 | }
102 |
103 | - (UILabel *)torchLab {
104 | if (!_torchLab) {
105 | _torchLab = [[UILabel alloc] init];
106 | _torchLab.text = @"轻触照亮";
107 | _torchLab.textAlignment = NSTextAlignmentCenter;
108 | _torchLab.textColor = [UIColor whiteColor];
109 | _torchLab.font = [UIFont systemFontOfSize:12];
110 | _torchLab.hidden = YES;
111 | }
112 | return _torchLab;
113 | }
114 |
115 | - (void)torchBtn_action:(UIButton *)btn {
116 | if (btn.selected) {
117 | btn.selected = NO;
118 | [btn setBackgroundImage:[UIImage imageNamed:@"wc_scan_torch"] forState:(UIControlStateNormal)];
119 | [SGTorch turnOffTorch];
120 | self.torchLab.text = @"轻触照亮";
121 | } else {
122 | btn.selected = YES;
123 | [btn setBackgroundImage:[UIImage imageNamed:@"wc_scan_torch_hl"] forState:(UIControlStateNormal)];
124 | self.torchLab.text = @"轻触关闭";
125 | [SGTorch turnOnTorch];
126 | }
127 | }
128 |
129 | - (UILabel *)tipsLab {
130 | if (!_tipsLab) {
131 | _tipsLab = [[UILabel alloc] init];
132 | _tipsLab.text = @"识别二维码";
133 | _tipsLab.textAlignment = NSTextAlignmentCenter;
134 | _tipsLab.textColor = [UIColor whiteColor];
135 | _tipsLab.font = [UIFont systemFontOfSize:17];
136 | }
137 | return _tipsLab;
138 | }
139 |
140 | - (UIImageView *)qrcodeImgView {
141 | if (!_qrcodeImgView) {
142 | _qrcodeImgView = [[UIImageView alloc] init];
143 | _qrcodeImgView.userInteractionEnabled = YES;
144 | _qrcodeImgView.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.5];
145 | _qrcodeImgView.image = [UIImage imageNamed:@"wc_scan_mine_qrcode"];
146 | }
147 | return _qrcodeImgView;
148 | }
149 |
150 | - (UILabel *)qrcodeLab {
151 | if (!_qrcodeLab) {
152 | _qrcodeLab = [[UILabel alloc] init];
153 | _qrcodeLab.text = @"我的二维码";
154 | _qrcodeLab.textAlignment = NSTextAlignmentCenter;
155 | _qrcodeLab.textColor = [UIColor whiteColor];
156 | _qrcodeLab.font = [UIFont systemFontOfSize:13];
157 | }
158 | return _qrcodeLab;
159 | }
160 |
161 | - (UIImageView *)albumImgView {
162 | if (!_albumImgView) {
163 | _albumImgView = [[UIImageView alloc] init];
164 | _albumImgView.userInteractionEnabled = YES;
165 | _albumImgView.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.5];
166 | _albumImgView.image = [UIImage imageNamed:@"wc_scan_album"];
167 | }
168 | return _albumImgView;
169 | }
170 |
171 | - (UILabel *)albumLab {
172 | if (!_albumLab) {
173 | _albumLab = [[UILabel alloc] init];
174 | _albumLab.text = @"相册";
175 | _albumLab.textAlignment = NSTextAlignmentCenter;
176 | _albumLab.textColor = [UIColor whiteColor];
177 | _albumLab.font = [UIFont systemFontOfSize:13];
178 | }
179 | return _albumLab;
180 | }
181 |
182 | - (void)showTorch {
183 | self.torchBtn.hidden = NO;
184 | self.torchLab.hidden = NO;
185 | self.tipsLab.hidden = YES;
186 | }
187 | - (void)dismissTorch {
188 | if (!self.torchBtn.isSelected) {
189 | self.torchBtn.hidden = YES;
190 | self.torchLab.hidden = YES;
191 | self.tipsLab.hidden = NO;
192 | }
193 | }
194 |
195 | - (void)addQRCodeTarget:(id)aTarget action:(SEL)aAction {
196 | UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:aTarget action:aAction];
197 | [self.qrcodeImgView addGestureRecognizer:tap];
198 | }
199 | - (void)addAlbumTarget:(id)aTarget action:(SEL)aAction {
200 | UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:aTarget action:aAction];
201 | [self.albumImgView addGestureRecognizer:tap];
202 | }
203 |
204 | @end
205 |
--------------------------------------------------------------------------------
/SGQRCodeExample/WebView/WebViewController.h:
--------------------------------------------------------------------------------
1 | //
2 | // WebViewController.h
3 | // SGQRCodeExample
4 | //
5 | // Created by kingsic on 16/8/29.
6 | // Copyright © 2016年 kingsic. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | typedef enum : NSUInteger {
12 | ComeFromWB,
13 | ComeFromWC
14 | } ComeFrom;
15 |
16 | @interface WebViewController : UIViewController
17 | /** 判断从哪个控制器 push 过来 */
18 | @property (nonatomic, assign) ComeFrom comeFromVC;
19 | /** 接收扫描的二维码信息 */
20 | @property (nonatomic, copy) NSString *jump_URL;
21 | /** 接收扫描的条形码信息 */
22 | @property (nonatomic, copy) NSString *jump_bar_code;
23 |
24 | @end
25 |
--------------------------------------------------------------------------------
/SGQRCodeExample/WebView/WebViewController.m:
--------------------------------------------------------------------------------
1 | //
2 | // WebViewController.m
3 | // SGQRCodeExample
4 | //
5 | // Created by kingsic on 16/8/29.
6 | // Copyright © 2016年 kingsic. All rights reserved.
7 | //
8 |
9 | #import "WebViewController.h"
10 | #import
11 |
12 | @interface WebViewController ()
13 | @property (nonatomic, strong) UILabel *barCodeLab;
14 | @property (nonatomic, strong) WKWebView *wkWebView;
15 | @property (nonatomic, strong) UIProgressView *progressView;
16 | @end
17 |
18 | @implementation WebViewController
19 |
20 | - (void)dealloc {
21 | NSLog(@"WebViewController - - dealloc");
22 |
23 | if (_wkWebView != nil) {
24 | [self.wkWebView removeObserver:self forKeyPath:NSStringFromSelector(@selector(estimatedProgress))];
25 | }
26 | }
27 |
28 | - (void)viewDidLoad {
29 | [super viewDidLoad];
30 | // Do any additional setup after loading the view.
31 | self.view.backgroundColor = [UIColor whiteColor];
32 |
33 | [self configNav];
34 |
35 | if (self.jump_bar_code) {
36 | [self.view addSubview:self.barCodeLab];
37 | } else {
38 | [self.view addSubview:self.wkWebView];
39 | [self.view addSubview:self.progressView];
40 |
41 | [self loadData];
42 | }
43 | }
44 |
45 | - (void)loadData {
46 | NSURL *url = [NSURL URLWithString:self.jump_URL];
47 | NSURLRequest *urlRequest = [NSURLRequest requestWithURL:url];
48 | [_wkWebView loadRequest:urlRequest];
49 | }
50 |
51 | - (WKWebView *)wkWebView {
52 | if (!_wkWebView) {
53 | CGRect frame = CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height);
54 | _wkWebView = [[WKWebView alloc] initWithFrame:frame];
55 | _wkWebView.navigationDelegate = self;
56 |
57 | [self.wkWebView addObserver:self forKeyPath:NSStringFromSelector(@selector(estimatedProgress)) options:0 context:nil];
58 | }
59 | return _wkWebView;
60 | }
61 |
62 | - (UIProgressView *)progressView {
63 | if (!_progressView) {
64 | _progressView = [[UIProgressView alloc] initWithProgressViewStyle:UIProgressViewStyleDefault];
65 | _progressView.trackTintColor = [UIColor clearColor];
66 | CGFloat statusBarHeight = [UIApplication sharedApplication].statusBarFrame.size.height;
67 | _progressView.frame = CGRectMake(0, statusBarHeight == 20 ? 64 : (statusBarHeight + 44), self.view.frame.size.width, 2);
68 | if (self.comeFromVC == ComeFromWB) {
69 | _progressView.tintColor = [UIColor orangeColor];
70 | } else {
71 | _progressView.tintColor = [UIColor greenColor];
72 | }
73 | }
74 | return _progressView;
75 | }
76 |
77 | /// KVO
78 | - (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context {
79 | if ([keyPath isEqualToString:NSStringFromSelector(@selector(estimatedProgress))] && object == self.wkWebView) {
80 | self.progressView.alpha = 1.0;
81 | BOOL animated = self.wkWebView.estimatedProgress > self.progressView.progress;
82 | [self.progressView setProgress:self.wkWebView.estimatedProgress animated:animated];
83 | if(self.wkWebView.estimatedProgress >= 0.97) {
84 | [UIView animateWithDuration:0.1 delay:0.3 options:UIViewAnimationOptionCurveEaseOut animations:^{
85 | self.progressView.alpha = 0.0;
86 | } completion:^(BOOL finished) {
87 | [self.progressView setProgress:0.0 animated:NO];
88 | }];
89 | }
90 | } else {
91 | [super observeValueForKeyPath:keyPath ofObject:object change:change context:context];
92 | }
93 | }
94 |
95 | /// 页面加载完成之后调用
96 | - (void)webView:(WKWebView *)webView didFinishNavigation:(WKNavigation *)navigation {
97 | self.navigationItem.title = self.wkWebView.title;
98 |
99 | self.progressView.alpha = 0.0;
100 | }
101 | /// 页面加载失败时调用
102 | - (void)webView:(WKWebView *)webView didFailNavigation:(WKNavigation *)navigation withError:(NSError *)error {
103 |
104 | self.progressView.alpha = 0.0;
105 | }
106 |
107 | - (void)configNav {
108 | UIButton *left_Button = [[UIButton alloc] init];
109 | [left_Button setTitle:@"back" forState:UIControlStateNormal];
110 | [left_Button setTitleColor:[UIColor colorWithRed: 21/ 255.0f green: 126/ 255.0f blue: 251/ 255.0f alpha:1.0] forState:(UIControlStateNormal)];
111 | [left_Button sizeToFit];
112 | [left_Button addTarget:self action:@selector(left_BarButtonItemAction) forControlEvents:UIControlEventTouchUpInside];
113 | UIBarButtonItem *left_BarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:left_Button];
114 | self.navigationItem.leftBarButtonItem = left_BarButtonItem;
115 |
116 | self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:(UIBarButtonSystemItemRefresh) target:self action:@selector(right_BarButtonItemAction)];
117 | }
118 |
119 | - (void)left_BarButtonItemAction {
120 | if (self.comeFromVC == ComeFromWB) {
121 | [self.navigationController popViewControllerAnimated:YES];
122 | }
123 |
124 | if (self.comeFromVC == ComeFromWC) {
125 | [self.navigationController popToRootViewControllerAnimated:YES];
126 | }
127 | }
128 |
129 | - (void)right_BarButtonItemAction {
130 | [self.wkWebView reload];
131 | }
132 |
133 | - (UILabel *)barCodeLab {
134 | if (!_barCodeLab) {
135 | _barCodeLab = [[UILabel alloc] init];
136 | _barCodeLab.frame = CGRectMake(0, 200, self.view.frame.size.width, 70);
137 | _barCodeLab.text = [NSString stringWithFormat:@"条形码:%@", self.jump_bar_code];
138 | _barCodeLab.textAlignment = NSTextAlignmentCenter;
139 | _barCodeLab.numberOfLines = 0;
140 | }
141 | return _barCodeLab;
142 | }
143 |
144 |
145 | @end
146 |
--------------------------------------------------------------------------------
/SGQRCodeExample/XC/Controller/XCQRCodeVC.h:
--------------------------------------------------------------------------------
1 | //
2 | // XCQRCodeVC.h
3 | // SGQRCodeExample
4 | //
5 | // Created by kingsic on 2022/7/11.
6 | // Copyright © 2022 kingsic. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | NS_ASSUME_NONNULL_BEGIN
12 |
13 | @interface XCQRCodeVC : UIViewController
14 |
15 | @end
16 |
17 | NS_ASSUME_NONNULL_END
18 |
--------------------------------------------------------------------------------
/SGQRCodeExample/XC/Controller/XCQRCodeVC.m:
--------------------------------------------------------------------------------
1 | //
2 | // XCQRCodeVC.m
3 | // SGQRCodeExample
4 | //
5 | // Created by kingsic on 2022/7/11.
6 | // Copyright © 2022 kingsic. All rights reserved.
7 | //
8 |
9 | #import "XCQRCodeVC.h"
10 | #import "SGQRCode.h"
11 | #import "WebViewController.h"
12 |
13 | @interface XCQRCodeVC () {
14 | SGScanCode *scanCode;
15 | }
16 | @property (nonatomic, strong) SGScanView *scanView;
17 | @property (nonatomic, strong) UILabel *promptLabel;
18 |
19 | @end
20 |
21 | @implementation XCQRCodeVC
22 |
23 | - (void)dealloc {
24 | NSLog(@"XCQRCodeVC - dealloc");
25 |
26 | [self stop];
27 | }
28 |
29 | - (void)start {
30 | [scanCode startRunning];
31 | [self.scanView startScanning];
32 | }
33 |
34 | - (void)stop {
35 | [scanCode stopRunning];
36 | [self.scanView stopScanning];
37 | }
38 |
39 | - (void)viewDidLoad {
40 | [super viewDidLoad];
41 | // Do any additional setup after loading the view from its nib.
42 | self.view.backgroundColor = [UIColor blackColor];
43 |
44 | [self configureNav];
45 |
46 | [self configureUI];
47 |
48 | [self configureQRCode];
49 | }
50 |
51 | - (void)configureUI {
52 | [self.view addSubview:self.scanView];
53 | [self.view addSubview:self.promptLabel];
54 | }
55 |
56 | - (void)configureQRCode {
57 | scanCode = [SGScanCode scanCode];
58 | scanCode.preview = self.view;
59 | scanCode.delegate = self;
60 | CGFloat w = 0.7;
61 | CGFloat x = 0.5 * (1 - w);
62 | CGFloat h = (self.view.frame.size.width / self.view.frame.size.height) * w;
63 | CGFloat y = 0.5 * (1 - h);
64 | /// 扫描范围。对应辅助扫描框的frame(borderFrame)设置
65 | scanCode.rectOfInterest = CGRectMake(y, x, h, w);
66 | [scanCode startRunning];
67 | }
68 |
69 | - (void)scanCode:(SGScanCode *)scanCode result:(NSString *)result {
70 | [self stop];
71 |
72 | [scanCode playSoundEffect:@"SGQRCode.bundle/scan_end_sound.caf"];
73 |
74 | WebViewController *jumpVC = [[WebViewController alloc] init];
75 | jumpVC.comeFromVC = ComeFromWC;
76 | [self.navigationController pushViewController:jumpVC animated:YES];
77 |
78 | if ([result hasPrefix:@"http"]) {
79 | jumpVC.jump_URL = result;
80 | } else {
81 | jumpVC.jump_bar_code = result;
82 | }
83 | }
84 |
85 | - (void)configureNav {
86 | self.navigationItem.title = @"扫一扫";
87 | self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"相册" style:(UIBarButtonItemStyleDone) target:self action:@selector(rightBarButtonItenAction)];
88 | }
89 |
90 | - (void)rightBarButtonItenAction {
91 | [SGPermission permissionWithType:SGPermissionTypePhoto completion:^(SGPermission * _Nonnull permission, SGPermissionStatus status) {
92 | if (status == SGPermissionStatusNotDetermined) {
93 | [permission request:^(BOOL granted) {
94 | if (granted) {
95 | NSLog(@"第一次授权成功");
96 | [self _enterImagePickerController];
97 | } else {
98 | NSLog(@"第一次授权失败");
99 | }
100 | }];
101 | } else if (status == SGPermissionStatusAuthorized) {
102 | NSLog(@"SGPermissionStatusAuthorized");
103 | [self _enterImagePickerController];
104 | } else if (status == SGPermissionStatusDenied) {
105 | NSLog(@"SGPermissionStatusDenied");
106 | NSDictionary *infoDict = [[NSBundle mainBundle] infoDictionary];
107 | NSString *app_Name = [infoDict objectForKey:@"CFBundleDisplayName"];
108 | if (app_Name == nil) {
109 | app_Name = [infoDict objectForKey:@"CFBundleName"];
110 | }
111 |
112 | NSString *messageString = [NSString stringWithFormat:@"[前往:设置 - 隐私 - 照片 - %@] 允许应用访问", app_Name];
113 | UIAlertController *alertC = [UIAlertController alertControllerWithTitle:@"温馨提示" message:messageString preferredStyle:(UIAlertControllerStyleAlert)];
114 | UIAlertAction *alertA = [UIAlertAction actionWithTitle:@"确定" style:(UIAlertActionStyleDefault) handler:nil];
115 |
116 | [alertC addAction:alertA];
117 | [self presentViewController:alertC animated:YES completion:nil];
118 | } else if (status == SGPermissionStatusRestricted) {
119 | NSLog(@"SGPermissionStatusRestricted");
120 | UIAlertController *alertC = [UIAlertController alertControllerWithTitle:@"温馨提示" message:@"由于系统原因, 无法访问相册" preferredStyle:(UIAlertControllerStyleAlert)];
121 | UIAlertAction *alertA = [UIAlertAction actionWithTitle:@"确定" style:(UIAlertActionStyleDefault) handler:nil];
122 | [alertC addAction:alertA];
123 | [self presentViewController:alertC animated:YES completion:nil];
124 | }
125 | }];
126 | }
127 |
128 | - (void)_enterImagePickerController {
129 | [self stop];
130 |
131 | UIImagePickerController *imagePicker = [[UIImagePickerController alloc] init];
132 | imagePicker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
133 | imagePicker.delegate = self;
134 | imagePicker.modalPresentationStyle = UIModalPresentationCustom;
135 | [self presentViewController:imagePicker animated:YES completion:nil];
136 | }
137 |
138 | #pragma mark - - UIImagePickerControllerDelegate 的方法
139 | - (void)imagePickerControllerDidCancel:(UIImagePickerController *)picker {
140 | [self dismissViewControllerAnimated:YES completion:nil];
141 | [self start];
142 | }
143 |
144 | - (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {
145 | UIImage *image = [info objectForKey:UIImagePickerControllerOriginalImage];
146 | [scanCode readQRCode:image completion:^(NSString *result) {
147 | if (result == nil) {
148 | [self dismissViewControllerAnimated:YES completion:nil];
149 | [self start];
150 | NSLog(@"未识别出二维码");
151 | } else {
152 | [self dismissViewControllerAnimated:YES completion:^{
153 | WebViewController *jumpVC = [[WebViewController alloc] init];
154 | jumpVC.comeFromVC = ComeFromWC;
155 | [self.navigationController pushViewController:jumpVC animated:YES];
156 |
157 | if ([result hasPrefix:@"http"]) {
158 | jumpVC.jump_URL = result;
159 | } else {
160 | jumpVC.jump_bar_code = result;
161 | }
162 | }];
163 | }
164 | }];
165 | }
166 |
167 | - (SGScanView *)scanView {
168 | if (!_scanView) {
169 | SGScanViewConfigure *configure = [[SGScanViewConfigure alloc] init];
170 | configure.cornerLocation = SGCornerLoactionInside;
171 | configure.cornerWidth = 1;
172 | configure.cornerLength = 25;
173 | configure.isShowBorder = YES;
174 | configure.scanlineStep = 2;
175 | configure.scanline = @"SGQRCode.bundle/scan_scanline";
176 | configure.autoreverses = YES;
177 |
178 | CGFloat x = 0;
179 | CGFloat y = 0;
180 | CGFloat w = self.view.frame.size.width;
181 | CGFloat h = self.view.frame.size.height;
182 | _scanView = [[SGScanView alloc] initWithFrame:CGRectMake(x, y, w, h) configure:configure];
183 | [_scanView startScanning];
184 | }
185 | return _scanView;
186 | }
187 |
188 | - (UILabel *)promptLabel {
189 | if (!_promptLabel) {
190 | _promptLabel = [[UILabel alloc] init];
191 | _promptLabel.backgroundColor = [UIColor clearColor];
192 | CGFloat promptLabelX = 0;
193 | CGFloat promptLabelY = 0.73 * self.view.frame.size.height;
194 | CGFloat promptLabelW = self.view.frame.size.width;
195 | CGFloat promptLabelH = 25;
196 | _promptLabel.frame = CGRectMake(promptLabelX, promptLabelY, promptLabelW, promptLabelH);
197 | _promptLabel.textAlignment = NSTextAlignmentCenter;
198 | _promptLabel.font = [UIFont boldSystemFontOfSize:13.0];
199 | _promptLabel.textColor = [[UIColor whiteColor] colorWithAlphaComponent:0.6];
200 | _promptLabel.text = @"将二维码/条码放入框内, 即可自动扫描";
201 | }
202 | return _promptLabel;
203 | }
204 |
205 | @end
206 |
--------------------------------------------------------------------------------
/SGQRCodeExample/main.m:
--------------------------------------------------------------------------------
1 | //
2 | // main.m
3 | // SGQRCodeExample
4 | //
5 | // Created by kingsic on 17/3/21.
6 | // Copyright © 2017年 kingsic. All rights reserved.
7 | //
8 |
9 | #import
10 | #import "AppDelegate.h"
11 |
12 | int main(int argc, char * argv[]) {
13 | @autoreleasepool {
14 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/SGQRCodeExampleTests/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleExecutable
8 | $(EXECUTABLE_NAME)
9 | CFBundleIdentifier
10 | $(PRODUCT_BUNDLE_IDENTIFIER)
11 | CFBundleInfoDictionaryVersion
12 | 6.0
13 | CFBundleName
14 | $(PRODUCT_NAME)
15 | CFBundlePackageType
16 | BNDL
17 | CFBundleShortVersionString
18 | 1.0
19 | CFBundleVersion
20 | 1
21 |
22 |
23 |
--------------------------------------------------------------------------------
/SGQRCodeExampleTests/SGQRCodeExampleTests.m:
--------------------------------------------------------------------------------
1 | //
2 | // SGQRCodeExampleTests.m
3 | // SGQRCodeExampleTests
4 | //
5 | // Created by kingsic on 17/3/21.
6 | // Copyright © 2017年 kingsic. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface SGQRCodeExampleTests : XCTestCase
12 |
13 | @end
14 |
15 | @implementation SGQRCodeExampleTests
16 |
17 | - (void)setUp {
18 | [super setUp];
19 | // Put setup code here. This method is called before the invocation of each test method in the class.
20 | }
21 |
22 | - (void)tearDown {
23 | // Put teardown code here. This method is called after the invocation of each test method in the class.
24 | [super tearDown];
25 | }
26 |
27 | - (void)testExample {
28 | // This is an example of a functional test case.
29 | // Use XCTAssert and related functions to verify your tests produce the correct results.
30 | }
31 |
32 | - (void)testPerformanceExample {
33 | // This is an example of a performance test case.
34 | [self measureBlock:^{
35 | // Put the code you want to measure the time of here.
36 | }];
37 | }
38 |
39 | @end
40 |
--------------------------------------------------------------------------------
/SGQRCodeExampleUITests/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleExecutable
8 | $(EXECUTABLE_NAME)
9 | CFBundleIdentifier
10 | $(PRODUCT_BUNDLE_IDENTIFIER)
11 | CFBundleInfoDictionaryVersion
12 | 6.0
13 | CFBundleName
14 | $(PRODUCT_NAME)
15 | CFBundlePackageType
16 | BNDL
17 | CFBundleShortVersionString
18 | 1.0
19 | CFBundleVersion
20 | 1
21 |
22 |
23 |
--------------------------------------------------------------------------------
/SGQRCodeExampleUITests/SGQRCodeExampleUITests.m:
--------------------------------------------------------------------------------
1 | //
2 | // SGQRCodeExampleUITests.m
3 | // SGQRCodeExampleUITests
4 | //
5 | // Created by kingsic on 17/3/21.
6 | // Copyright © 2017年 kingsic. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface SGQRCodeExampleUITests : XCTestCase
12 |
13 | @end
14 |
15 | @implementation SGQRCodeExampleUITests
16 |
17 | - (void)setUp {
18 | [super setUp];
19 |
20 | // Put setup code here. This method is called before the invocation of each test method in the class.
21 |
22 | // In UI tests it is usually best to stop immediately when a failure occurs.
23 | self.continueAfterFailure = NO;
24 | // UI tests must launch the application that they test. Doing this in setup will make sure it happens for each test method.
25 | [[[XCUIApplication alloc] init] launch];
26 |
27 | // In UI tests it’s important to set the initial state - such as interface orientation - required for your tests before they run. The setUp method is a good place to do this.
28 | }
29 |
30 | - (void)tearDown {
31 | // Put teardown code here. This method is called after the invocation of each test method in the class.
32 | [super tearDown];
33 | }
34 |
35 | - (void)testExample {
36 | // Use recording to get started writing UI tests.
37 | // Use XCTAssert and related functions to verify your tests produce the correct results.
38 | }
39 |
40 | @end
41 |
--------------------------------------------------------------------------------