Giter Club home page Giter Club logo

sgqrcode's Introduction

前沿

  • 在此感谢那些曾经对 SGQRCode 提出宝贵建议者

  • 这是对iOS原生二维码生成与扫描的总结 (之所以在此做总结:是为了方便更多的人去很好的使用iOS原生二维码生成与扫描的这块知识点)

  • 扫描二维码界面采取了微信二维码界面的布局

  • 轻轻的我走了,正如我轻轻的来,我动一动鼠标,就是为了给你 Star (喜欢的朋友别忘了哦 😊 😊)

  • 代码后期不断更新维护中 (当前代码是:最原汁原味的代码,为的是方便更多的人对这块知识点的灵活运用;后期会抽取一定的时间,对代码进行一定的封装处理。注:生成二维码代码封装已经完成(2016、12、2);扫描二维码部分代码封装已经完成(2017、1、19))

  • 注:真机测试相机权限问题,请运行之后拔掉数据线,进行测试

主要内容的介绍

  • 普通二维码生成

  • 彩色二维码生成

  • 带有小图标二维码生成

  • 扫描二维码的自定义

  • 是否开启闪光灯

  • 从相册中获取二维码

  • 扫描成功之后提示音

  • 扫描成功之后的界面之间的跳转

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

生成二维码

  • 普通二维码生成
imageView.image = [SGQRCodeTool SG_generateWithDefaultQRCodeData:@"https://github.com/kingsic" imageViewWidth:imageViewW];
  • logo 二维码生成
imageView.image = [SGQRCodeTool SG_generateWithLogoQRCodeData:@"https://github.com/kingsic" logoImageName:@"icon_image" logoScaleToSuperView:scale];
  • 彩色二维码生成
imageView.image = [SGQRCodeTool SG_generateWithColorQRCodeData:@"https://github.com/kingsic" backgroundColor:[CIColor colorWithRed:1 green:0 blue:0.8] mainColor:[CIColor colorWithRed:0.3 green:0.2 blue:0.4]];

扫描二维码

  • 扫描视图创建
self.scanningView = [[SGScanningQRCodeView alloc] initWithFrame:self.view.frame outsideViewLayer:self.view.layer];
[self.view addSubview:self.scanningView];
  • 扫描二维码方法
// 初始化链接对象(会话对象)
self.session = [[AVCaptureSession alloc] init];
// 实例化预览图层, 传递_session是为了告诉图层将来显示什么内容
self.previewLayer = [AVCaptureVideoPreviewLayer layerWithSession:_session];
[SGQRCodeTool SG_scanningQRCodeOutsideVC:self session:_session previewLayer:_previewLayer];

更新介绍

      1. 30 --> 新增从相册中获取二维码功能 (注意: 从相册中读取二维码, 需要在 iOS8.0 以后)
      1. 1 --> 新增扫描成功之后提示音
      1. 9 --> 新增 SGAlertView 提升界面美观
      1. 12 --> 解决 iOS 10 相机访问权限崩溃的问题以及解决从相册中读取二维码重复 push 问题(一张照片中包含多个二维码,这里会选取第一个二维码进行解读)
      1. 22 --> 解决 XCode 8 控制台打印问题
      1. 27 --> 解决从相册中读取二维码,取消选择返回时,图层卡死问题(修改了创建扫描边框里的问题)
      1. 2 --> 新增 SGQRCodeTool,对生成二维码代码进行封装(只需一句代码进行调用);删除了 CIImage 分类
      1. 22 --> 解决用户相机访问权限的问题
      1. 29 --> 对扫描二维码部分代码的封装,从相册中读取二维码采用新方法;扫描视图布局采用CALayer

效果图

Concluding remarks

sgqrcode's People

Contributors

kingsic avatar

Watchers

James Cloos 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.