项目介绍:
示例可用于二维码及条形码扫描功能二维码生成
仓库地址 https://github.com/XueYangLee/QRCodeScan
扫描情形下存有扫描框及输入框的切换功能,不需要可以直接注释掉相关代码
- (void)captureOutput:(AVCaptureOutput *)captureOutput didOutputMetadataObjects:(NSArray *)metadataObjects fromConnection:(AVCaptureConnection *)connection{
if (metadataObjects.count > 0) {
[CodeScanTools openShake:YES Sound:YES];
[self.session stopRunning];
[self.link removeFromRunLoop:[NSRunLoop mainRunLoop] forMode:NSRunLoopCommonModes];
AVMetadataMachineReadableCodeObject *obj = [metadataObjects lastObject];
if (obj) {
//二维码信息回传
//NSLog(@">>>>>>>>>>>>%@>>>>",[obj stringValue]);
[self scanCodeResult:[obj stringValue]];
}
}
}
二维码生成可生成纯二维码及带图片的二维码功能
/**
生成一张普通的二维码
*/
+ (UIImage *)generateWithDefaultQRCodeData:(NSString *)data imageViewWidth:(CGFloat)imageViewWidth {
CIFilter *filter = [CIFilter filterWithName:@"CIQRCodeGenerator"];
[filter setDefaults];
NSString *info = data;
NSData *infoData = [info dataUsingEncoding:NSUTF8StringEncoding];
[filter setValue:infoData forKeyPath:@"inputMessage"];
CIImage *outputImage = [filter outputImage];
return [self createNonInterpolatedUIImageFormCIImage:outputImage withSize:imageViewWidth];
}