Latest 1.0.6
Homepage https://github.com/liufan321/HMQRCodeScanner
License MIT
Platforms ios 8.0, requires ARC
Frameworks AVFoundation
Authors

包含 UI 界面的轻量级二维码扫描及生成框架

功能

  • 提供一个导航控制器,扫描 二维码 / 条形码
  • 能够生成指定 字符串 + avatar(可选) 的二维码名片
  • 能够识别相册图片中的二维码(iOS 64 位设备)

系统支持

  • iOS 8.0+
  • Xcode 7.0

安装

CocoaPods

  • 进入终端,cd 到项目目录,输入以下命令,建立 Podfile
$ pod init
  • Podfile 中输入以下内容:
platform :ios, '8.0'
use_frameworks!

pod 'HMQRCodeScanner'
  • 在终端中输入以下命令,安装 Pod
$ pod install

使用

  • Info.plist 中添加两个 值对 以授权访问 相机相册

    • NSCameraUsageDescription
    • NSPhotoLibraryUsageDescription

Objective-C

  • 导入框架
@import HMQRCodeScanner;
  • 打开扫描控制器,扫描及完成回调
NSString *cardName = @"天涯刀哥 - 傅红雪";
UIImage *avatar = [UIImage imageNamed:@"avatar"];

// 实例化扫描控制器
HMScannerController *scanner = [HMScannerController scannerWithCardName:cardName avatar:avatar completion:^(NSString *stringValue) {

    self.scanResultLabel.text = stringValue;
}];

// 设置导航栏样式
[scanner setTitleColor:[UIColor whiteColor] tintColor:[UIColor greenColor]];

// 展现扫描控制器
[self showDetailViewController:scanner sender:nil];
  • 生成二维码名片
NSString *cardName = @"天涯刀哥 - 傅红雪";
UIImage *avatar = [UIImage imageNamed:@"avatar"];

[HMScannerController cardImageWithCardName:cardName avatar:avatar scale:0.2 completion:^(UIImage *image) {
    self.imageView.image = image;
}];

Swift

  • 导入框架
import HMQRCodeScanner
  • 打开扫描控制器,扫描及完成回调
let cardName = "天涯刀哥 - 傅红雪"
let avatar = UIImage(named: "avatar")

let scanner = HMScannerController.scannerWithCardName(cardName, avatar: avatar) { (stringValue) -> Void in
    self.scanResultLabel.text = stringValue
}

self.showDetailViewController(scanner, sender: nil)
  • 生成二维码名片
let cardName = "天涯刀哥 - 傅红雪"
let avatar = UIImage(named: "avatar")

HMScannerController.cardImageWithCardName(cardName, avatar: avatar, scale: 0.2) { (image) -> Void in
    self.imageView.image = image
}

Latest podspec

{
    "name": "HMQRCodeScanner",
    "version": "1.0.6",
    "summary": "u5305u542b UI u754cu9762u7684u8f7bu91cfu7ea7u4e8cu7ef4u7801u626bu63cfu53cau751fu6210u6846u67b6",
    "homepage": "https://github.com/liufan321/HMQRCodeScanner",
    "license": "MIT",
    "authors": {
        "Fan Liu": "[email protected]"
    },
    "platforms": {
        "ios": "8.0"
    },
    "source": {
        "git": "https://github.com/liufan321/HMQRCodeScanner.git",
        "tag": "1.0.6"
    },
    "source_files": "HMQRCodeScanner/QRCode/*.{h,m}",
    "resources": "HMQRCodeScanner/QRCode/HMScanner.bundle",
    "frameworks": "AVFoundation",
    "requires_arc": true
}

Pin It on Pinterest

Share This