二维码生成与扫描

2016-07-19  本文已影响35人  CCloud

1.生成二维码

  self.imageView.image = [[CCQRcodeTool sharedInstance] createQRCodeImageWithString:self.textView.text size:200.0 iconImage:[UIImage imageNamed:@"geng"]];          

2.扫描二维码

 CCQRcodeTool *qrTool = [CCQRcodeTool sharedInstance];
[qrTool beginScanInView:self.view result:^(NSArray<NSString *> *resultStrs) {
    NSLog(@"resultStrs %@",resultStrs);
    self.label.text = resultStrs.lastObject;
}];
[qrTool setInsteretRect:self.scanView.frame];
qrTool.drawCodeFrameFlag = YES;     

3.从相册照片中获取二维码

 [[CCQRcodeTool sharedInstance]distinguishQRCodeFromImage:image result:^(NSArray<NSString *> *resultStrs) {
    self.label.text = resultStrs.lastObject;
}];    

详见二维码扫描demo

上一篇下一篇

猜你喜欢

热点阅读