Latest 1.0.1
Homepage https://github.com/MaoJianxiang/BarQrcodeWork
License MIT
Platforms ios 8.0
Authors

CI Status
Version
License
Platform

1.0.1 特性

BarQrcodeWork有两个类:
1.BarcodeGenerator 处理生成条形码和生成二维码的类方法。
2.ScanBarcodeViewController 处理扫描条码的方法。

注意,在使用扫描时需要用到相册,所以需要在工程的info.plist中添加 NSCameraUsageDescription key 即Privacy – Camera Usage Description设置String值。

不然会出现崩溃报错:
contain an NSCameraUsageDescription key with a string value explaining to the user how the app uses this data.

原理

生成二维码主要是靠<CoreImage/CoreImage.h>中的滤镜CIFilter类分别设置它的name类型为CICode128BarcodeGenerator和CIQRCodeGenerator,就可以生成对应的条形码和二维码。
扫描条码:
1.输入源(配置摄像头)
2.邮会话将摄像头采集到的条码转换成字符串数据
3.输入数据
4.邮预览图层显示扫描场景
最后我是通过代理的方式将结果返回。

使用

  • 生成条形码

barcodeString:传入数据
size:生成一维码的图片大小

  • (UIImage )createBarcodeImageString:(NSString )barcodeString imagSize:(CGSize)size;
  • 生成二维码

QRString:传入数据
with:生成二维码的图片大小
image:想要二维码中间有个logo,就可以传过来,否则可以传nil

  • (UIImage )createQRImageString:(NSString )QRString imageWidth:(CGFloat)width logo:(UIImage *)image;
  • 扫描条码

通过代理方法传回扫描结果
-(void)didFinishResultForScanBarcodeViewController:(ScanBarcodeViewController )scanBarcodeViewController resultValue:(NSString )resultString;

初始化ScanBarcodeViewController对象是设置代理,遵守ScanBarcodeViewControllerDelegate,在协议的取得结果并处理ScanBarcodeViewController对象的返回。

Author

毛建祥, 邮箱: [email protected]

License

BarQrcodeWork is available under the MIT license. See the LICENSE file for more info.

Latest podspec

{
    "name": "BarQrcodeWork",
    "version": "1.0.1",
    "summary": "This is the framework of a deal with barcode.",
    "description": "This is a framework that to provide generate bar code and qr code interface and the method of scanning.",
    "homepage": "https://github.com/MaoJianxiang/BarQrcodeWork",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "MaoJianxiang": "[email protected]"
    },
    "source": {
        "git": "https://github.com/MaoJianxiang/BarQrcodeWork.git",
        "tag": "1.0.1"
    },
    "platforms": {
        "ios": "8.0"
    },
    "source_files": "BarQrcodeWork/Classes/**/*"
}

Pin It on Pinterest

Share This