SYBarcodeManager二维码的扫描与生成

来源:互联网 发布:广联达软件怎么使用 编辑:程序博客网 时间:2024/05/21 18:42

SYBarcodeManager

扫描二维码

代码示例

// 导入头文件#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];
原创粉丝点击