Giter Site home page Giter Site logo

mmscan's Introduction

MMScan

Building Building CocoaPods compatible Platform License: MIT

Introduction

MMScan是一个简单的二维码以及条码扫描工具,使用Objective-C语言开发,有一套自定义的扫描动画以及界面,还包括生成二维码以及条码【一行代码搞定】

MMScan is an simple QRCode and barcode scanning tool,Contains a separate set of interfaces and a single call, as well as the generation of QRCode code and bar code, a line of code can run.

Rquirements

  • iOS 8.0+
  • Xcode 9
  • Xcode 8

Installation

Install with Cocoapods

记得更新你的pod-master,命令pod repo update master

  • pod 'MMScan', '~> 0.0'
  • #import <MMScan/MMScanViewController.h> in you code

Copy code into project

克隆代码,然后将MMScanner文件夹下面的所有文件【包含资源】加入到你的项目中即可。

Just clone and add the folder MMScanner to your project.

Example

Usage

下面仅介绍简单的使用,具体使用见MMScanDemo

引入头文件#import "MMScanViewController.h",如果是使用cocoapods,则需要引入#import <MMScan/MMScanViewController.h>

PS:注意事项 因为会调用到相册和相机权限,所以一定要记得在info.plist文件中添加必要的权限代码

<key>NSCameraUsageDescription</key>
<string>App需要您的同意,才能访问相机</string>
<key>NSPhotoLibraryUsageDescription</key>
<string>App需要您的同意,才能访问相册</string>
<key>NSPhotoLibraryAddUsageDescription</key>
<string>App需要您的同意,才能添加图片到相册</string>

扫描二维码&条码

MMScanViewController *scanVc = [[MMScanViewController alloc] initWithQrType:MMScanTypeAll onFinish:^(NSString *result, NSError *error) {
    if (error) {
        NSLog(@"error: %@",error);
    } else {
        NSLog(@"扫描结果:%@",result);
    }
}];
[self.navigationController pushViewController:scanVc animated:YES];
注释
  1. QrType

    有三种值:【MMScanTypeAll、MMScanTypeQrCode、MMScanTypeBarCode】

    • MMScanTypeAll 界面下方有个菜单,支持切换二维码和条码的扫描
    • MMScanTypeQrCode 单纯的二维码扫描
    • MMScanTypeBarCode 单纯的条码扫描
  2. 回调结果

    回调回来的是扫描结果,如果是多张二维码,也只返回一条数据【数组中的第一条】

生成二维码以及条码

//生成二维码
UIImage *image = [MMScanViewController createQRImageWithString:_linkTfd.text QRSize:CGSizeMake(250, 250) QRColor:[UIColor blackColor] bkColor:[UIColor colorWithRed:0.318 green:0.690 blue:0.839 alpha:1.00]];

//如果不需要设置背景色以及前景色,则使用下面代码  默认白色底黑色码
UIImage *image = [ScanViewController createQRImageWithString:_linkTfd.text QRSize:CGSizeMake(250, 250)];

//生成条形码
UIImage *image = [MMScanViewController createBarCodeImageWithString:_linkTfd.text QRSize:CGSizeMake(250, 150) QRColor:[UIColor blackColor] bkColor:[UIColor colorWithRed:0.318 green:0.690 blue:0.839 alpha:1.00]];

//如果不需要设置背景色以及前景色,则使用下面代码  默认白色底黑色码
UIImage *image = [ScanViewController createBarCodeImageWithString:_linkTfd.text barSize:CGSizeMake(250, 150)];


Contribution

You are welcome to fork and submit pull requests.

License

MMScan is open-sourced software licensed under the MIT license.

mmscan's People

Contributors

minmao-hub avatar

Watchers

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