Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/itenfay/DYFCodeScanner
一个简单的二维码和条码扫描器,有一套自定义的扫描动画以及界面,支持相机缩放,还可以生成和识别二维码。(A simple QR code and barcode scanner, which has a set of custom scanning animation and interface, supports camera zooming, and can generate and identify QR code.)
https://github.com/itenfay/DYFCodeScanner
barcode barcode-scanner center-image ios objective-c qrcode qrcode-generator qrcode-scanner
Last synced: 21 days ago
JSON representation
一个简单的二维码和条码扫描器,有一套自定义的扫描动画以及界面,支持相机缩放,还可以生成和识别二维码。(A simple QR code and barcode scanner, which has a set of custom scanning animation and interface, supports camera zooming, and can generate and identify QR code.)
- Host: GitHub
- URL: https://github.com/itenfay/DYFCodeScanner
- Owner: itenfay
- License: other
- Created: 2019-05-05T21:20:36.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2024-06-16T14:39:43.000Z (6 months ago)
- Last Synced: 2024-10-31T15:48:13.370Z (about 1 month ago)
- Topics: barcode, barcode-scanner, center-image, ios, objective-c, qrcode, qrcode-generator, qrcode-scanner
- Language: Objective-C
- Homepage: https://www.jianshu.com/p/571a17a68ec5
- Size: 13 MB
- Stars: 17
- Watchers: 1
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome - DYFCodeScanner - 一个二维码/条形码的扫码器,代码简洁高效。(A QR code and Barcode scanner for iOS. Its code is concise and efficient.) 【 [Priview](https://github.com/itenfay/DYFCodeScanner/raw/master/images/CodeScannerPreview.gif) 】 (OOM-Leaks-Crash / Scan)
README
如果能帮助到你,请你给[一颗星](https://github.com/itenfay/DYFCodeScanner),谢谢!(If this can help you, please give it a [star](https://github.com/itenfay/DYFCodeScanner), Thanks!)
## DYFCodeScanner
一个简单的二维码和条码扫描器,有一套自定义的扫描动画以及界面,支持相机缩放,还可以生成和识别二维码。(A simple QR code and barcode scanner, which has a set of custom scanning animation and interface, supports camera zooming, and can generate and identify QR code.)
[![License MIT](https://img.shields.io/badge/license-MIT-green.svg?style=flat)](LICENSE)
[![CocoaPods](http://img.shields.io/cocoapods/v/DYFCodeScanner.svg?style=flat)](http://cocoapods.org/pods/DYFCodeScanner)
![CocoaPods](http://img.shields.io/cocoapods/p/DYFCodeScanner.svg?style=flat)## Group (ID:614799921)
## Installation
Using [CocoaPods](https://cocoapods.org):
```
pod 'DYFCodeScanner'
```Or
```
pod 'DYFCodeScanner', '~> 1.3.1'
```## Preview
## Usage
- 添加隐私 (Add Privacy)
```
NSCameraUsageDescription
扫描二维码/条形码,允许App访问您的相机?
NSPhotoLibraryAddUsageDescription
存取照片,允许App访问您的相册?
NSPhotoLibraryUsageDescription
存取照片,允许App访问您的相册?
```- 导入头文件 (Import Header)
```
#import "DYFCodeScan.h"
```- 扫描二维码/条形码 (Scanning QRcode / Barcode)
1. 支持push和模态两种场景过渡。 (Supporting push or modal transition.)
2. 根据项目的需求,选择之一即可。(According to the needs of the project, you can choose one of them.)
3. 当你要推进视图控制器,你可以选择隐藏或者不隐藏导航条。(When you want to push the view controller, you can choose to or not to hide the navigation bar.)```
- (IBAction)scan:(id)sender {
static BOOL shouldPush = YES;
static BOOL naviBarHidden = YES;DYFCodeScanViewController *codesVC = [[DYFCodeScanViewController alloc] init];
codesVC.scanType = DYFCodeScanTypeAll;
codesVC.navigationTitle = @"二维码/条形码";
codesVC.tipString = [NSString stringWithFormat:@"将二维码/条形码放入框内,即自动扫描"];
codesVC.resultHandler = ^(BOOL result, NSString *stringValue) {
if (result) {
[self showResult:stringValue];
} else {
NSLog(@"QRCode Message: %@", stringValue);
}
};if (shouldPush) {
codesVC.navigationBarHidden = naviBarHidden = !naviBarHidden;
[self.navigationController pushViewController:codesVC animated:YES];
} else {
[self presentViewController:codesVC animated:YES completion:NULL];
}shouldPush = !shouldPush;
}- (void)showResult:(NSString *)value {
if (self.m_textView.text.length > 0) {
self.m_textView.text = @"";
}
self.m_textView.text = value;
}
```- 生成二维码 (Generating QR code)
1. 生成带中心图像的二维码 (Generating QR code that contains center image)
```
- (IBAction)generateQRCode:(id)sender {
CGRect rect = self.qrc_imageView.frame;
DYFQRCodeImageView *imageView = [DYFQRCodeImageView createWithFrame:rect stringValue:@"http://img.shields.io/cocoapods/v/DYFAssistiveTouchView.svg?style=flat" centerImage:[UIImage imageNamed:@"cat49334.jpg"]];
self.qrc_imageView.image = imageView.image;
}
```2. 生成带颜色的二维码 (Generating QR code that contains backgroudColor and foregroudColor)
```
- (IBAction)generateColorQRCode:(id)sender {
CGRect rect = self.cqrc_imageView.frame;
DYFQRCodeImageView *imageView = [DYFQRCodeImageView createWithFrame:rect stringValue:@"http://img.shields.io/cocoapods/p/DYFAssistiveTouchView.svg?style=flat" backgroudColor:[UIColor grayColor] foregroudColor:[UIColor greenColor]];
self.cqrc_imageView.image = imageView.image;
}
```3. 生成带中心图像颜色的二维码 (Generating QR code that contains center image, backgroudColor and foregroudColor)
```
DYFQRCodeImageView *imageView = [DYFQRCodeImageView createWithFrame:CGRectMake(30, 88, 200, 200) stringValue:@"https://github.com/itenfay/DYFAuthIDAndGestureLock" backgroudColor:[UIColor grayColor] foregroudColor:[UIColor greenColor] centerImage:[UIImage imageNamed:@"cat49334.jpg"]];
[self.view addSubview:imageView];
```- 识别二维码 (Recognizing QR code)
```
- (void)recognizeQRCode:(UILongPressGestureRecognizer *)recognizer {
UIImage *qrcodeImage = ((DYFQRCodeImageView *)recognizer.view).image;
NSString *stringValue = [qrcodeImage yf_stringValue];
#if DEBUG
NSLog(@"stringValue: %@", stringValue);
#endif
}
```## Sample
- [Code Sample Portal](https://github.com/itenfay/DYFCodeScanner/blob/master/Basic%20Files/ViewController.m)