qrCodeGenerator()
Generates a quick response (QR) code image.
Declaration
class func qrCodeGenerator() -> any CIFilter & CIQRCodeGeneratorReturn Value
The generated image.
Discussion
This method generates a QR code as an image. QR codes are a high-density matrix barcode format defined in the ISO/IEC 18004:2006 standard.
The QR code generator filter uses the following properties:
messageA
stringrepresenting the data to be encoded as a QR Code as NSData.correctionLevelA single letter
stringrepresenting the error-correction format as an NSString. L is 7 percent correction, M is 15 percent correction, Q is 25 percent correction, and H is 30 percent correction.
The following code creates a filter that generates a QR code:
func qrCode(inputMessage: String) -> CIImage {
let qrCodeGenerator = CIFilter.qrCodeGenerator()
qrCodeGenerator.message = inputMessage.data(using: .ascii)!
qrCodeGenerator.correctionLevel = "H"
return qrCodeGenerator.outputImage!
}[Image]
See Also
Filters
attributedTextImageGenerator()aztecCodeGenerator()barcodeGenerator()blurredRectangleGenerator()checkerboardGenerator()code128BarcodeGenerator()lenticularHaloGenerator()meshGenerator()pdf417BarcodeGenerator()randomGenerator()roundedRectangleGenerator()roundedRectangleStrokeGenerator()starShineGenerator()stripesGenerator()sunbeamsGenerator()