A simple QR Code scan solution with only system API and smooth animation.
Copy the source code in the /QRCodeScan folder into your project, then use it like UIViewController
. Please check details in Demo project.
Create the QRCodeScanViewController
and present it:
QRCodeScanViewController *scanViewController = [[QRCodeScanViewController alloc] init];
scanViewController.continuous = YES;
scanViewController.scanInterval = 1.5;
scanViewController.delegate = self;
[self presentViewController:scanViewController animated:YES completion:nil];
//Other customizations
//scanViewController.scanWindowCornerColor = UIColor.redColor;
//scanViewController.scanWindowFrame = CGRectMake(100, 100, 100, 100);
//scanViewController.textAboveScanWindow = @"Scan QRcode";
//scanViewController.textAboveScanWindowMargin = 20.0;
//Could be pushed by an UINavigationController
//[self.navigationController pushViewController:scanViewController animated:YES];
Handle the QRCode scanned:
#pragma mark - QRCodeScanViewControllerDelegate
-(void)QRCodeScanViewController:(QRCodeScanViewController *)qrCodeScanViewController qrCodeDidScanned:(NSString *)qrCode {
NSLog(@"QRCode Scanned:%@",qrCode);
//Usually, we dismiss the QRCodeScanViewController after QRCode scanned
[qrCodeScanViewController dismissViewControllerAnimated:YES completion:nil];
}
The scan time interval, continuous scanning, scan window corner color and its frame could be customed.
[中文]
这是一个简单轻量的二维码识别方案。它只使用了系统API,具备平滑的动画效果。
拷贝QRCodeScan目录下源代码到您的项目中,就可以像使用UIViewController
那样使用它。 可参考Demo项目。
简要代码请参考以上英文介绍。
扫描的时间间隔,是否持续扫描,扫描窗角颜色和位置大小可定制。
StepIndicator is released under the MIT license. See LICENSE for details.