GithubHelp home page GithubHelp logo

xuebkang / sgqrcode Goto Github PK

View Code? Open in Web Editor NEW

This project forked from kingsic/sgqrcode

0.0 1.0 0.0 7.6 MB

The easy to use QRCode scan library for iOS【iOS 原生二维码生成与扫描 -> 高仿微信】

License: Apache License 2.0

Objective-C 99.25% Ruby 0.75%

sgqrcode's Introduction

SGQRCode

  • QQ群:825339547

  • 温馨提示:v3.0.0 Block 取代 Delegate

主要内容的介绍

  • 生成二维码

  • 扫描二维码

  • 从相册中读取二维码

  • 根据光线强弱开启手电筒

  • 扫描成功之后界面之间逻辑跳转处理

  • 扫描界面可自定义(线扫描条样式以及网格样式)

  • 扫描界面仿微信(请根据项目需求,自行布局或调整)

SGQRCode 集成

  • 1、CocoaPods 导入 pod 'SGQRCode', '~> 3.0.1'

  • 2、下载、拖拽 “SGQRCode” 文件夹到工程中

代码介绍 (详细使用,请参考 Demo)

1、在 info.plist 中添加以下字段(iOS 10 之后需添加的字段)

  • NSCameraUsageDescription (相机权限访问)

  • NSPhotoLibraryUsageDescription (相册权限访问)

2、二维码扫描

    __weak typeof(self) weakSelf = self;

    /// 创建二维码扫描
    SGQRCodeObtainConfigure *configure = [SGQRCodeObtainConfigure QRCodeObtainConfigure];
    [obtain establishQRCodeObtainScanWithController:self configure:configure];
    // 二维码扫描回调方法
    [obtain setBlockWithQRCodeObtainScanResult:^(SGQRCodeObtain *obtain, NSString *result) {
        <#code#>
    }];
    // 二维码扫描开启方法: 需手动开启
    [obtain startRunningWithBefore:^{
        // 在此可添加 HUD
    } completion:^{
        // 在此可移除 HUD
    }];
    // 根据外界光线强弱值判断是否自动开启手电筒
    [obtain setBlockWithQRCodeObtainScanBrightness:^(SGQRCodeObtain *obtain, CGFloat brightness) {
        <#code#>
    }];
    
    /// 从相册中读取二维码    
    [obtain establishAuthorizationQRCodeObtainAlbumWithController:self];
    // 从相册中读取图片上的二维码回调方法
    [obtain setBlockWithQRCodeObtainAlbumResult:^(SGQRCodeObtain *obtain, NSString *result) {
        <#code#>
    }];

3、二维码生成

    /// 常规二维码
    _imageView.image = [SGQRCodeObtain generateQRCodeWithData:@"https://github.com/kingsic" size:size];
    
    /// 带 logo 的二维码
    _imageView.image = [SGQRCodeObtain generateQRCodeWithData:@"https://github.com/kingsic" size:size logoImage:logoImage ratio:ratio];

效果图

问题及解决方案

  • 若在使用 CocoaPods 安装第三方时,出现 [!] Unable to find a specification for SGQRCode 提示时,打开终端先输入 pod repo remove master;执行完毕后再输入 pod setup 即可 (可能会等待一段时间)

  • iOS 从相册中读取条形码/二维码遇到的问题

  • iOS 扫描支持 7.0+;从相册中读取二维码支持 8.0+;因此,CocoaPods 版本最低支持 8.0+

更新介绍

  • 2016-09-30 :新增从相册中读取二维码功能

  • 2016-10-27 :解决从相册中读取二维码,取消选择返回时,图层卡死问题(修改了创建扫描边框问题)

  • 2017-01-29 :对扫描二维码部分代码的封装;扫描视图布局采用 CALayer

  • 2017-03-21 :v2.0.0 使用继承的**进行二维码扫描管理

  • 2017-05-16 :v2.0.5 使用封装的**进行二维码扫描管理

  • 2017-06-26 :v2.1.0 加入 CocoaPods 管理

  • 2017-08-17 :v2.1.5 新增根据光线强弱判断是否打开手电筒

  • 2017-08-23 :v2.1.6 扫描界面使用 UIBezierPath 布局且可根据不同需求实现自定义(扫描线条以及网格样式)

  • 2018-02-08 :v2.2.0 新增新浪微博示例、新增从相册中读取二维码失败回调函数以及分类名称的更换

  • 2018-11-09 :v3.0.0 版本升级 Block 取代 Delegate(具体相关信息介绍请在 releases 中查看)

  • 2018-11-27 :v3.0.1 SGQRCodeObtain 类中新增二维码生成方法

License

SGQRCode is released under the Apache License 2.0. See LICENSE for details.

sgqrcode's People

Contributors

kingsic avatar liaoxiaoyue avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.