二维码生成与扫描
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;
}];