原生封装二维码、条形码扫描工具;生成、识别(彩色)二维码、条形码图片
pod 'ZHBarTool'
UIImage *image = [ZBarTool encodeQRCodeImageWithContent:@"https://www.apple.com" size:300 backgroundColor:[UIColor clearColor] themeColor:[UIColor purpleColor] insetImage:[UIImage imageNamed:@"beautiful"] imageCornerRadius:50];
self.imageView.image = image;
NSString *content = [ZBarTool decodeQRCodeImage:self.imageView.image];
self.label.text = content;
ZBarTool *tool = [ZBarTool barTool];
[tool startScanBarWithScanRect:self.scanRect scanType:ZBarScanTypeAll layerView:self.view];
tool.scanBarGetObject = ^(NSString * _Nonnull objects) {
NSLog(@"%@", objects);
};
UIImage *image = [ZHBarTool encodeBarcodeImageWithContent:@"12345678" size:CGSizeMake(self.view.frame.size.width-20, 100) color:[UIColor yellowColor]];
self.barcodeImageView.image = image;
ZBarSacnView *scanView = [[ZBarSacnView alloc] initWithFrame:self.view.bounds scanRect:self.scanRect];
[self.view addSubview:scanView];
[scanView startScanBar];