代码示例
// 导入头文件
#import "SYBarcodeManager.h"
// 实例化
SYBarcodeManager *scanningBarcode = [[SYBarcodeManager alloc] init];
// 属性设置
scanningBarcode.scanRadius = 50.0;
scanningBarcode.showScanline = YES;
scanningBarcode.scanlineColor = [UIColor redColor];
scanningBarcode.showScanCorner = YES;
scanningBarcode.scanCornerColor = [UIColor greenColor];
// 方法调用
// 首次调用扫描二维码
[scanningBarcode barcodeScanningWithFrame:CGRectMake(60.0, (CGRectGetHeight(self.view.bounds) - (CGRectGetWidth(self.view.bounds) - 60.0 * 2)) / 2, (CGRectGetWidth(self.view.bounds) - 60.0 * 2), (CGRectGetWidth(self.view.bounds) - 60.0 * 2)) view:self.view complete:^(NSString *scanResult) {
[[[UIAlertView alloc] initWithTitle:nil message:scanResult delegate:nil cancelButtonTitle:nil otherButtonTitles:@"ok", nil] show];
}];
// 停止扫描二维码
[scanningBarcode barcodeScanningCancel];
// 重新扫描二维码
[scanningBarcode barcodeScanningStart];
代码示例
// 指定大小和颜色
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];