CocoaPods trunk is moving to be read-only. Read more on the blog, there are 14 months to go.
| TestsTested | ✓ |
| LangLanguage | SwiftSwift |
| License | MIT |
| ReleasedLast Release | Nov 2016 |
| SwiftSwift Version | 3.0 |
| SPMSupports SPM | ✗ |
Maintained by Alexander Schuch.
A QRCode generator written in Swift.
Create a new QRCode representing a URL, a string or arbitrary data. The following examples all result in the same QRCode image.
// URL
let url = URL(string: "http://schuch.me")!
let qrCode = QRCode(url)
qrCode?.image
// String
let qrCode = QRCode("http://schuch.me")
qrCode?.image
// NSData
let data = "http://schuch.me".data(using: .isoLatin1)!
let qrCode = QRCode(data)
qrCode.imageMake sure to declare your
QRCodeinstance as a variable in order make use of the following features.
Adjust Output Size
Change the output size of the QRCode output image via the size property.
qrCode.size = CGSize(width: 300, height: 300)
qrCode.image // UIImage (300x300)Color
Modify the colors of the QRCode output image via color and backgroundColor properties.
qrCode.color = CIColor(rgba: "16a085")
qrCode.backgroundColor = CIColor(rgba: "000")
qrCode.image // UIImage (green QRCode color and black background)Note: The above examples make use of the
CIColorextension that ships with this project to create colors based on HEX strings.
For convenience, a UIImageView extension is provided to directly initialize an image view with an instance of QRCode.
let imageView = UIImageView(qrCode: qrCode)In case you love emoji as much as I do, make sure to create your QRCode instance using the
let qrCode = 🔳("http://example.com")Current Swift compatibility breakdown:
| Swift Version | Framework Version |
|---|---|
| 3.0 | master |
| 2.3 | 1.x |
| 2.2 | 0.x |
Just drag and drop the three .swift files in the QRCode folder into your project.
Open the Xcode project and press ⌘-U to run the tests.
Alternatively, all tests can be run from the terminal using xctool.
xctool -scheme QRCodeTests -sdk iphonesimulator testFeel free to get in touch.