Updated 2 January 2018
Hi Guys , Are you searching for a quick QR code scanner and generator now here is the one. This post will tell you about…
How to generate and scan a QR code using this fabulous library named
Its available on Github https://github.com/liufan321/SwiftQRCode
Install the library using CocoaPods and follow these steps and rest will happen itself .
To scan a QR code :-
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
let scanner = QRCode() override func viewDidLoad() { super.viewDidLoad() scanner.prepareScan(view) { (stringValue) -> () in println(stringValue) } scanner.scanFrame = view.bounds } override func viewDidAppear(animated: Bool) { super.viewDidAppear(animated) // start scan scanner.startScan() } |
Don’t forget to request for NSCameraUsageDescription in the info.plist
The above code will start your camera into your given scan frame and return the encoded information as String into the prepare scan closure.
To generate a QR code :-
1 |
iconView.image = QRCode.generateImage("Hello SwiftQRCode", avatarImage: UIImage(named: "avatar"), avatarScale: 0.3) |
The method includes three parameters.
Now you can easily generate and scan the QRCode and save your development time.
SEE YA ….
If you have more details or questions, you can reply to the received confirmation email.
Back to Home
Be the first to comment.