Latest 1.1
Homepage https://github.com/dexianyinjiu/MMQRCodeScanner
License MIT
Platforms ios 7.0, requires ARC
Frameworks Foundation, UIKit, AVFoundation
Authors

License MIT 
CocoaPods 
CocoaPods 

这是一个使用于iOS系统的二维码扫描和制作工具,带有UI,UI也可根据属性自行修改。支持条形码扫描以及识别图片中的二维码,制作二维码可以指定颜色、大小、可嵌入logo。

MMQRCodeScanner

安装 [CocoaPods]

  1. pod 'MMQRCodeScanner', '~> 1.1';
  2. pod install / pod update;
  3. #import <MMQRCodeScanner/MMScannerController.h>;
  4. plist需添加Privacy - Camera Usage DescriptionPrivacy - Photo Library Usage Description

扫描的使用方式:

MMScannerController外部可修改属性如下,使用时可自行设置。

//透明的区域[扫描区 | 默认:左边距40,上边距80]
@property (nonatomic, assign) CGRect qrScanArea;
//动画间隔时间[默认值:0.01s]
@property (nonatomic, assign) double qrScanLineAnimateDuration;
//四角颜色[默认:R:0/255.5  G:200.0/255.0  B:94.0/255.0]
@property (nonatomic, strong) UIColor *qrScanLayerBorderColor;
//扫描线图片[默认:使用resource下的scan_line]
@property (nonatomic, copy) NSString *qrScanLineImageName;
//是否支持条码[默认显示:NO]
@property (nonatomic, assign) BOOL supportBarcode;
//是否显示'闪光灯'[默认显示:NO]
@property (nonatomic, assign) BOOL showFlashlight;
//是否显示'图库'[默认显示:NO]
@property (nonatomic, assign) BOOL showGalleryOption;
//扫描内容回传
@property (nonatomic, copy) void (^completion)(NSString *scanConetent);

//## 扫描控制
- (void)startScan;
- (void)stopScan;

示例如下:

_scanner = [[MMScannerController alloc] init];
_scanner.showGalleryOption = YES;
_scanner.showFlashlight = YES;
_scanner.supportBarcode = YES;
[_scanner setCompletion:^(NSString *scanConetent) {
    UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"扫描内容如下:"
                                                        message:scanConetent
                                                       delegate:weakSelf
                                              cancelButtonTitle:@"确定"
                                              otherButtonTitles:nil, nil];
    [alertView show];
}];
[self.navigationController pushViewController:_scanner animated:YES];

制作的使用方式:

MMQRCodeMakerUtil提供同步和异步制作方式:

/**
制作二维码[同步]

@param qrContent 二维码内容
@param logoImage 中间的填充图片[logo]
@param qrColor 二维码颜色
@param qrWidth 二维码宽度
@return 二维码
*/
+ (UIImage *)qrImageWithContent:(NSString *)qrContent
                      logoImage:(UIImage *)logoImage
                        qrColor:(UIColor *)qrColor
                        qrWidth:(CGFloat)qrWidth;

/**
制作二维码[异步]

@param qrContent 二维码内容
@param logoImage 中间的填充图片[logo]
@param qrColor 二维码颜色
@param qrWidth 二维码宽度
@param completion 完成回调
*/
+ (void)qrImageWithContent:(NSString *)qrContent
                 logoImage:(UIImage *)logoImage
                   qrColor:(UIColor *)qrColor
                   qrWidth:(CGFloat)qrWidth
                completion:(void (^)(UIImage *image))completion;

示例如下:

NSString *qrContent = @"Hello, this is a two-dimensional code";
UIImage *qrImage = [MMQRCodeMakerUtil qrImageWithContent:qrContent
                                               logoImage:[UIImage imageNamed:@"logo.jpg"]
                                                 qrColor:[UIColor blackColor]
                                                 qrWidth:240];

使用要求

iOS 8.0+
Xcode 7.0+

许可证

MIT

Latest podspec

{
    "name": "MMQRCodeScanner",
    "version": "1.1",
    "summary": "A two-dimensional code scanning and making tools used on iOS.",
    "homepage": "https://github.com/dexianyinjiu/MMQRCodeScanner",
    "license": "MIT",
    "authors": {
        "u5f97u95f2u996eu9152": "[email protected]"
    },
    "source": {
        "git": "https://github.com/dexianyinjiu/MMQRCodeScanner.git",
        "tag": "1.1"
    },
    "platforms": {
        "ios": "7.0"
    },
    "requires_arc": true,
    "source_files": "MMQRCodeScanner/**/*.{h,m}",
    "resources": "MMQRCodeScanner/Resources/*.png",
    "frameworks": [
        "Foundation",
        "UIKit",
        "AVFoundation"
    ]
}

Pin It on Pinterest

Share This