二维码生成与扫描

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 *resultStrs) {
    NSLog(@"resultStrs %@",resultStrs);
    self.label.text = resultStrs.lastObject;
}];
[qrTool setInsteretRect:self.scanView.frame];
qrTool.drawCodeFrameFlag = YES;     

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

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

详见二维码扫描demo

你可能感兴趣的:(二维码生成与扫描)