Using the system API (AVFoundation) for packaging, including the UI interface and QR code, barcode scanning, generating and other operations
Objective-C Version: ZZYQRCode
platform :ios, '8.0'
use_frameworks!
pod 'ZZYQRCodeSwift', '~> 1.1.0'
- Create sessionManager
let session = AVCaptureSessionManager(captureType: .AVCaptureTypeBoth, scanRect: CGRect.null, success: SuccessBlock)
- Show view
session.showPreViewLayerIn(view: view)
- Scan sound effects
var isPlaySound = false
var soundName:String?
- Torch
session.turnTorch(state: torchState)
- Scan the QR code in the album
session.scanPhoto(image: UIImage, success: SuccessBlock)
- Check authorization status
class func checkAuthorizationStatusForCamera(grant:@escaping GrantBlock, denied:DeniedBlock)
- Create QR code
let image = UIImage.createQRCode(size: 200, dataStr: "hello")
- Create customize QR code
let image = UIImage(named: "bigMax")
QRImage.image = UIImage.createCustomizeQRCode(size: 200,
dataStr: "hello",
imageType: .CircularImage,
iconImage: image!,
iconImageSize: 40)
Because of iOS10 authorization change,you need to add code in your info.plist
<key>NSCameraUsageDescription</key>
<string></string>
<key>NSPhotoLibraryUsageDescription</key>
<string></string>