Latest 0.9.2
Homepage https://github.com/geroembser/ShapeQRCode
License MIT
Platforms ios 12.0

Installation

Preferred installation is using CocoaPods.

To Integrate the ShapeQRCode into your project using CocoaPods, specify it in your Podfile:

pod 'ShapeQRCode'

After that, continue using the following command:

$ pod install

Usage

Basically there’re a ton of different customizations ShapeQRCode supports. I will explain the different possibilities here in a more detailled documentation soon. But for now, it may be very interesting to look at the example project and its code. The example project demonstrates most of the different capabilities of ShapeQRCode.

But for completeness, here’s a short comprehension of how to generate a QR code in Swift.

import ShapeQRCode

//use an emoji as the image in the middle
let 🦒 = "🦒".image()!

//create the image that should be contained in the qr code
let img = try? ShapeQRCode.Image(withUIImage: 🦒,
                                 width: 0.7,
                                 height: 0.7,
                                 transparencyDetectionEnabled: true)

//the actual struct that encapsulates the QR code data
let qr = ShapeQRCode(withText: "https://en.wikipedia.org/wiki/Giraffe",
                     andImage: img,
                     shape: .circle,
                     moduleSpacingPercent: 0.002,
                     color: .black,
                     errorCorrectionLevel: .high)

//Render the qr code represented by the qr as an UIImage with 500px width/height
let renderedQRImage = qr.image(withLength: 500)                  

The final result looks like this:

QR code with giraffe and rounded dots as modules

You can find this code in the playground in this repo. Clone/Download the repo and open the workspace. Then build using "ShapeQRCode" scheme (important!) and run the playground.

Example

For an example, where you can play around with the QR Code as well, see the sample project included in this repo.
The code used there may also help you to integrate the appropriate solution of a ShapeQRCode into your project.

Contributing

Do you like that repo? Are there any issues? (obviously there’s a lot…) Submit a pull request, open an issue…
And: I’m always happy to hear your feedback! If you have any questions or suggestions, I’m glad to help you!

License

This project is licensed under the MIT License – see the LICENSE file for details

Acknowledgments

This library uses the great 🎉 QR Code generator library from Nayuki. Check it out! ➡️ https://github.com/nayuki/QR-Code-generator

Latest podspec

{
    "name": "ShapeQRCode",
    "version": "0.9.2",
    "authors": "Gero Embser",
    "homepage": "https://github.com/geroembser/ShapeQRCode",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "summary": "Swift QR code generator where the black squares can be replaced by shapes and images can be included in the QRCode",
    "source": {
        "git": "https://github.com/geroembser/ShapeQRCode.git",
        "tag": "0.9.2",
        "submodules": true
    },
    "platforms": {
        "ios": "12.0"
    },
    "swift_version": "4.2",
    "source_files": [
        "Source/*.{swift,h,m}",
        "nayuki-QR-Code-Generator/c/qrcodegen.{h,c}"
    ],
    "private_header_files": [
        "Source/QRCode.h",
        "nayuki-QR-Code-Generator/c/qrcodegen.h"
    ],
    "pod_target_xcconfig": {
        "SWIFT_INCLUDE_PATHS": "$(SRCROOT)/**"
    },
    "preserve_paths": "module.modulemap",
    "compiler_flags": "-w"
}

Pin It on Pinterest

Share This