Swift—QR Codes in 2 Minutes

Learn how to easily generate QR codes in Swift.

Artturi Jalli
Geek Culture

--

Image Credit: Author

QR Codes in a Nutshell

QR codes are barcodes that can store some information. You can scan QR codes with a smartphone camera. A common use case for QR codes is to open a specific website with a QR scanner.

Photo by Markus Winkler on Unsplash

How To Create a QR Code

Generating QR codes to your iOS app is very easy: Swift comes with a built-in QR code generator. In Swift, a QR code is nothing but a regular UIImage in which the QR code is rendered.

Here is all the code you need to generate a QR code image:

To display the QR code (i.e. an UIImage) you can add an image view to your storyboard:

--

--

Artturi Jalli
Geek Culture

Check @jalliartturi on YouTube to become a successful blogger. (For collabs, reach me out at: artturi@bloggersgoto.com)