NOTE: Want to explore EFQRCode interactively? Get our user guide as Swift Playground here.
Efqrcode: a pure swift development of art two-dimensional code generation library.Official website; video. Vimideoplayer: a simple encapsulation of avplayer and avplayerlayer classes.Official website; MobilePlayer: a powerful and fully customizable IOS media player.Official website; PDF. Reader: the core of an IOS PDF reader.Official website. A category dedicated to hardware related libs back to top. All libraries and projects - 17. EFQRCode, BluetoothKit, NextLevel, QRCodeReader.swift, and RxBluetoothKit.
1. Recognition
There are two equivalent ways:
or
Because of the possibility that more than one QR code exist in the same image, the return value is a [String]. If the returned array is empty, we could not recognize/didn’t find any QR code in the image.
2. Generation
Again, there are two equivalent ways of doing this:
or
The return value is of type CGImage?. If it is nil, something went wrong during generation.
Parameters Explained
content: String?
Content is a required parameter, with its capacity limited at 1273 characters. The density of the QR-lattice increases with the increases of the content length. For example:
| 10 characters | 250 characters |
|---|
mode: EFQRCodeMode
Mode of QR Code is defined as EFQRCodeMode:
nil | grayscale | binarization |
|---|
binarization threshold:
mode nil | 0.3 | 0.5 | 0.8 |
|---|
inputCorrectionLevel: EFInputCorrectionLevel
Percent of tolerance (which we default to H defined below) has 4 different levels: L 7% / M 15% / Q 25% / H 30%.
Comparison of different input correction levels (generating for the same content):
| L | M | Q | H |
|---|
size: EFIntSize
NOTE: will be ignored if magnification is not nil
Length and height of the generated QR code, defaults to 256 by 256. EFIntSize is just like CGSize, but width and height are Int instead of CGFloat.
| 234 * 234 | 312 * 234 |
|---|
magnification: EFIntSize?
Magnification is defined as the ratio of actual size to the smallest possible size, and defaults to nil.
Directly setting the size parameter results in low resolution QR code images, so setting the magnification is recommended instead. If you already have a desired size in mind, we have two helpers methods at your disposal to calculate the magnification that results in the closet dimension: EFQRCodeGenerator.maxMagnification(lessThanOrEqualTo:) and EFQRCodeGenerator.minMagnification(greaterThanOrEqualTo:).
| size 300 | magnification 9 |
|---|
backgroundColor: CIColor/CGColor
Background color, defaults to white.
foregroundColor: CIColor/CGColor
Foreground color (for code points), defaults to black.
| Foreground color set to red | Background color set to gray |
|---|
icon: CGImage?
Icon image in the center of QR code image, defaults to nil.
iconSize: CGFloat?
Size of icon image, defaults to 20% of QR code size if nil.
| Default 20% size | Set to 64 |
|---|
watermark: CGImage?
Background watermark image, defaults to nil.
watermarkMode: EFWatermarkMode
Position of watermark in the QR code, defaults to EFWatermarkMode.scaleAspectFill. Think of the generated QR code like UIImageView and EFWatermarkMode as UIView.ContentMode.
isWatermarkOpaque: Bool
Treat watermark image as opaque, defaults to false (use transparency).
false | true |
|---|
Efr Code
pointOffset: CGFloat
WARNING: Generated QR code might be hard to recognize with this parameter.
Efa Code In Mplus
Foreground point offset, defaults to 0.

| 0 | 0.5 |
|---|
pointShape: EFPointShape
Shape of foreground code points, defaults to EFPointShape.square.
| square | circle | diamond |
|---|
3. Generation from GIF
Eforcedemo
First you should get the complete Data of a GIF file
NOTE: You shall not get Data from UIImage as it only provides the first frame.
Efr Codec
Then you can create GIF QRCode with EFQRCode.generateGIF:
| Parameter | Description |
|---|---|
generator | REQUIRED, an EFQRCodeGenerator instance with other settings |
data | REQUIRED, encoded input GIF |
delay | Output QRCode GIF delay, emitted means no change |
loopCount | Times looped in GIF, emitted means no change |
The generator here is an instance of EFQRCodeGenerator, as demonstrated above, for configuring other parameters for individual frames in GIF. You can checkout the demo projects for more information.
The result (seizure WARNING) will be something like this:
Qr Code App
Now you can get the complete data of output QRCode GIF, next we can save it to local path / system photo library / upload to server or some other things you want to do;
