Latest 1.0
License MIT
Platforms ios 10.0, requires ARC

Scan QR、Generate QR Code image and Read QR Code from image


1. Scan QR

SwiftQRTools provide a SwiftQRScanController and a default view SwiftQRScanView shows in above picture. You can use yourself view just inherit SwiftQRScanView. And there’s some usefull delegate methods in SwiftQRScanControllerDelegate. Here’s an example:

class ViewController: UIViewController {
    // ...
    @IBAction func scanQR(_ sender: Any?) {
        let scanVC = SwiftQRScanController()
        scanVC.delegate = self
        self.present(scanVC, animated: true, completion: nil)
    // ...

extension ViewController: SwiftQRScanControllerDelegate {

    func scanController(_ controller: SwiftQRScanController, didFinishScanWithInfo info: String) {
        controller.dismiss(animated: false, completion: nil)

    func scanMetadataObjectTypes(_ for: SwiftQRScanController) -> [AVMetadataObject.ObjectType] {
        return [.qr, .code128, .ean13, .ean8]

    // SwiftQRScanViewConfig used to configure the interest rect.
   func scanViewConfigure(_ for: SwiftQRScanController) -> SwiftQRScanViewConfig {

        return SwiftQRScanViewConfig(colorExceptInterestRect: UIColor.init(white: 0, alpha: 0.8),
                                    interstRectWidth: 300.0,
                                    interstRectHeight: 100.0,
                                    InterestRectCornerLineLength: 40,
                                    InterestRectCornerLineWidth: 10)

    func scanView(_ for: SwiftQRScanController, in superView: UIView) -> SwiftQRScanView {

        let scanView = ScanViewWithBack(frame: superView.bounds)
        scanView.delegate = self
        return scanView

2. Generate QR Code

let image = SwiftQRUtils.generateQRCode(with: "123", tintColor:, imageScale: 10, centerImage: UIImage(named: "top"), centerImageSize: CGSize(width: 40, height: 40)) 

or just

let image = SwiftQRUtils.generateQRCode(with: "123") 

2. Read QR Code info from image

let image = UIImage(named: "test")
let result = SwiftQRUtils.getQRCodeInfo(in: image)
print("info is : (result)")


SimpleQR is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod 'SwiftQRTools'


SwiftQRUtils is released under the MIT license. See LICENSE for details.

Latest podspec

    "name": "SwiftQRTools",
    "version": "1.0",
    "summary": "Scan QRu3001Generate QR Code and read QR Code info from image.",
    "description": "Scan QRu3001Generate QR Code and read QR Code info from image.",
    "homepage": "",
    "license": "MIT",
    "authors": {
        "git": "[email protected]"
    "platforms": {
        "ios": "10.0"
    "source": {
        "git": "",
        "tag": "1.0"
    "source_files": "SwiftQRTools/SwiftQRTools/*.swift",
    "requires_arc": true,
    "swift_version": "5.0"

Pin It on Pinterest

Share This