扫描二维码
代码示例
// 导入头文件
#import "SYBarcodeManager.h"
// 实例化
SYBarcodeManager *scanningBarcode = [[SYBarcodeManager alloc] initWithFrame:self.view.bounds view:self.view];
// 属性设置
scanningBarcode.maskColor = [UIColor orangeColor];
scanningBarcode.scanlineColor = [UIColor redColor];
scanningBarcode.scanCornerColor = [UIColor greenColor];
scanningBarcode.scanFrame = CGRectMake(60.0, 100.0, 80.0, 80.0);
// 开始扫描
[scanningBarcode barcodeScanningStart:^(NSString *scanResult) {
NSLog(@"scanResult = %@", scanResult);
[[[UIAlertView alloc] initWithTitle:nil message:scanResult delegate:nil cancelButtonTitle:nil otherButtonTitles:@"ok", nil] show];
}];
// 结束扫描
[scanningBarcode barcodeScanningCancel];
生成二维码
代码示例
// 指定大小和颜色
CGFloat width = (CGRectGetWidth(self.view.bounds) - 10.0 * 2);
UIImage *image = [SYBarcodeManager barcodeImageWithContent:@"https://github.com/potato512/BarcodeManager" size:width colorRed:10.0 colorGreen:100.0 colorBlue:50.0];
// 指定大小
CGFloat width = (CGRectGetWidth(self.view.bounds) - 10.0 * 2);
UIImage *image = [SYBarcodeManager barcodeImageWithContent:@"https://github.com/potato512/BarcodeManager" size:width];