{"id":13715527,"url":"https://github.com/kingsic/SGQRCode","last_synced_at":"2025-05-07T04:30:59.714Z","repository":{"id":43026166,"uuid":"66864317","full_name":"kingsic/SGQRCode","owner":"kingsic","description":"The easy to use bar code and QR code scan library for iOS【支持二维码生成、读取图片中二维码、条形码和二维码扫描】","archived":false,"fork":false,"pushed_at":"2024-02-02T07:16:28.000Z","size":53739,"stargazers_count":1693,"open_issues_count":13,"forks_count":370,"subscribers_count":39,"default_branch":"master","last_synced_at":"2025-04-30T07:02:19.210Z","etag":null,"topics":["barcode","qrcode"],"latest_commit_sha":null,"homepage":"","language":"Objective-C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/kingsic.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-08-29T17:19:47.000Z","updated_at":"2025-04-27T02:03:51.000Z","dependencies_parsed_at":"2024-06-18T12:26:52.909Z","dependency_job_id":"95730fab-69ae-4874-a18b-3daf9b352491","html_url":"https://github.com/kingsic/SGQRCode","commit_stats":{"total_commits":180,"total_committers":5,"mean_commits":36.0,"dds":"0.16666666666666663","last_synced_commit":"41f0640ba8b1e29576121acab72635a7c9c52d17"},"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kingsic%2FSGQRCode","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kingsic%2FSGQRCode/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kingsic%2FSGQRCode/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kingsic%2FSGQRCode/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kingsic","download_url":"https://codeload.github.com/kingsic/SGQRCode/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251864141,"owners_count":21656289,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["barcode","qrcode"],"created_at":"2024-08-03T00:01:00.153Z","updated_at":"2025-05-07T04:30:54.698Z","avatar_url":"https://github.com/kingsic.png","language":"Objective-C","funding_links":[],"categories":["Objective-C  Stars 1000以内排名整理","OOM-Leaks-Crash","Objective-C","Libraries"],"sub_categories":["Scan","Objective-C"],"readme":"\n# SGQRCode\n\n| Version | UIKit | Use |\n|:-----:|:-----:|:-----:|\n| 3.5x    | iOS 9.0+  | Block\n| 4.x     | iOS 11.0+ | Delegate\n\n* QQ群：825339547\n\n* [3.5.1版本 API 使用说明](https://github.com/kingsic/SGQRCode/wiki/3.5.1版本API说明)\n\n\n## 主要功能\n\n`生成二维码`\u003cbr\u003e\n\n`扫描二维码`\u003cbr\u003e\n\n`捕获内容缩放功能`\u003cbr\u003e\n\n`图片中识别二维码`\u003cbr\u003e\n\n`相机、相册权限判断`\u003cbr\u003e\n\n`根据光线强弱开启关闭手电筒`\u003cbr\u003e\n\n`扫描成功后界面间的逻辑跳转处理`\u003cbr\u003e\n\n`扫描界面可高度自定义（满足所有主流app）`\u003cbr\u003e\n\n\n## 主要类说明\n| 类名 | 说明 |\n|-----|-----|\n| SGScanCode    | 扫描二维码 |\n| SGScanViewConfigure     | 扫描视图配置 |\n| SGScanView     | 扫描视图 |\n| SGPermission     | 相册、相机权限管理 |\n| SGTorch     | 手电筒管理 |\n| SGQRCodeLog     | 调试日志 |\n\n\n## SGQRCode 集成流程\n\n**手动集成**\n\n`添加 SGQRCode 文件夹到工程中`\n\n**通过 CocoaPods 集成**\n\n`pod 'SGQRCode', '~\u003e 4.1.0'`\n\n\n**Info.plist 添加以下字段**\n\n`NSCameraUsageDescription (相机权限访问)`\u003cbr\u003e\n\n`NSPhotoLibraryUsageDescription (相册权限访问)`\u003cbr\u003e\n\n\n**引用头文件**\n\n`#import \u003cSGQRCode/SGQRCode.h\u003e`\n\n\n**扫描二维码相关代码**\n```Objective-C\n// 创建二维码扫描类\nscanCode = [SGScanCode scanCode];\n\n// 预览视图，必须设置\nscanCode.preview = self.view;\n\n// 遵循 SGScanCodeDelegate\nscanCode.delegate = self;\n\n// 遵循 SGScanCodeSampleBufferDelegate\nscanCode.sampleBufferDelegate = self;\n\n// 开启扫描\n[scanCode startRunning];\n\n// 结束扫描\n[scanCode stopRunning];\n```\n\n**Delegate 方法**\n```Objective-C\n// SGScanCodeDelegate\n- (void)scanCode:(SGScanCode *)scanCode result:(NSString *)result {\n    \u003c#code#\u003e\n}\n\n// SGScanCodeSampleBufferDelegate\n- (void)scanCode:(SGScanCode *)scanCode brightness:(CGFloat)brightness {\n    \u003c#code#\u003e\n}\n```\n\n**图片中识别二维码方法**\n```Objective-C\n[scanCode readQRCode:image completion:^(NSString *result) {\n    \u003c#code#\u003e\n}];\n```\n\n**生成二维码相关方法**\n```Objective-C\n// 普通二维码生成方法\n[SGGenerateQRCode generateQRCodeWithData:data size:size];\n\n// 带 logo 的二维码生成方法\n[SGGenerateQRCode generateQRCodeWithData:data size:size logoImage:logoImage ratio:ratio];\n```\n\n\n## 效果图\n\n\u003cimg src=\"https://github.com/kingsic/SGQRCode/raw/master/Pictures/sgqrcode_1.png\" width=\"40%\" height=\"40%\"\u003e  \u003cimg src=\"https://github.com/kingsic/SGQRCode/raw/master/Pictures/sgqrcode_2.png\" width=\"40%\" height=\"40%\"\u003e\n\u003cimg src=\"https://github.com/kingsic/SGQRCode/raw/master/Pictures/sgqrcode_3.png\" width=\"40%\" height=\"40%\"\u003e  \u003cimg src=\"https://github.com/kingsic/SGQRCode/raw/master/Pictures/sgqrcode_4.png\" width=\"40%\" height=\"40%\"\u003e\n\u003cimg src=\"https://github.com/kingsic/SGQRCode/raw/master/Pictures/sgqrcode_5.png\" width=\"40%\" height=\"40%\"\u003e  \u003cimg src=\"https://github.com/kingsic/SGQRCode/raw/master/Pictures/sgqrcode_6.png\" width=\"40%\" height=\"40%\"\u003e\n\n\n## 问题及解决方案\n\n* 若在使用 CocoaPods 安装第三方时，出现 [!] Unable to find a specification for SGQRCode 提示时，打开终端先输入 pod repo remove master；执行完毕后再输入 pod setup 即可 (可能会等待一段时间)\n\n* CIDetector 类只能识别图片中的二维码，目前暂不支持识别图片中的条形码 [解决方案](https://juejin.cn/post/6844903910428114952l)\n\n\n## 更新说明\n\n* 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) 中查看\n\n* 2022-07-16 ：v4.0.0 版本重构：Delegate 取代 Block，新增手动对焦功能，优化拓展扫描视图，更多内容请在 [releases](https://github.com/kingsic/SGQRCode/releases/tag/4.0.0) 中查看\n\n* 2022-07-16 ：v4.1.0 优化SGScanView内部代码逻辑，修复无扫描线时，导致程序崩溃问题\n\n\n## License\nSGQRCode is released under the Apache License 2.0. See [LICENSE](https://github.com/kingsic/SGQRCode/blob/master/LICENSE) for details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkingsic%2FSGQRCode","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkingsic%2FSGQRCode","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkingsic%2FSGQRCode/lists"}