-
Recognizes and returns the contents of a QR code
image
.Note
If the returned array is empty, there’s no recognizable content in the QR codeimage
.Declaration
Swift
public static func recognize(_ image: CGImage) -> [String]
Parameters
image
a QR code to recognize.
Return Value
an array of contents recognized from
image
.
-
generate(for:
encoding: inputCorrectionLevel: size: magnification: backgroundColor: foregroundColor: watermark: watermarkMode: watermarkIsTransparent: icon: iconSize: pointStyle: pointOffset: isTimingPointStyled: mode: ) Generates a QR code image.
Declaration
Swift
public static func generate( for content: String, encoding: String.Encoding = .utf8, inputCorrectionLevel: EFInputCorrectionLevel = .h, size: EFIntSize = EFIntSize(width: 600, height: 600), magnification: EFIntSize? = nil, backgroundColor: CGColor = .white()!, foregroundColor: CGColor = .black()!, watermark: CGImage? = nil, watermarkMode: EFWatermarkMode = .scaleAspectFill, watermarkIsTransparent isWatermarkTransparent: Bool = true, icon: CGImage? = nil, iconSize: EFIntSize? = nil, pointStyle: EFPointStyle = EFSquarePointStyle.square, pointOffset: CGFloat = 0, isTimingPointStyled: Bool = false, mode: EFQRCodeMode? = nil ) -> CGImage?
Parameters
content
The message of the QR code.
encoding
The encoding to use for
content
.inputCorrectionLevel
The level of error tolerance percentage.
size
The size of the output image, ignored if
magnification
is set.magnification
The ratio of final size to smallest possible size
backgroundColor
Background color of the QR code, defaults to white.
foregroundColor
Foreground color for code points, defaults to black.
watermark
The background image to use, if any.
watermarkMode
How to position the
watermark
, defaults to aspect fill.isWatermarkTransparent
Wether to use the alpha channel in watermark image.
icon
The icon that appears in the center of QR code image, if any.
iconSize
Size of the
icon
, defaults to 20% ofsize
.pointStyle
Foreground code point style, defaults to square.
pointOffset
How much are foreground points shifted.
isTimingPointStyled
Wether the timing points should be styled (or remain square).
mode
The color rendering mode, defaults to original colors.
Return Value
The generated QR code image.
-
generateGIF(for:
encoding: inputCorrectionLevel: size: magnification: backgroundColor: foregroundColor: watermark: watermarkMode: watermarkIsTransparent: icon: iconSize: pointStyle: pointOffset: isTimingPointStyled: mode: ) Generates an animated QR code image.
Declaration
Swift
public static func generateGIF( for content: String, encoding: String.Encoding = .utf8, inputCorrectionLevel: EFInputCorrectionLevel = .h, size: EFIntSize = EFIntSize(width: 600, height: 600), magnification: EFIntSize? = nil, backgroundColor: CGColor = .white()!, foregroundColor: CGColor = .black()!, watermark: Data, watermarkMode: EFWatermarkMode = .scaleAspectFill, watermarkIsTransparent isWatermarkTransparent: Bool = true, icon: CGImage? = nil, iconSize: EFIntSize? = nil, pointStyle: EFPointStyle = EFSquarePointStyle.square, pointOffset: CGFloat = 0, isTimingPointStyled: Bool = false, mode: EFQRCodeMode? = nil ) -> Data?
Parameters
content
The message of the QR code.
encoding
The encoding to use for
content
.inputCorrectionLevel
The level of error tolerance percentage.
size
The size of the output image, ignored if
magnification
is set.magnification
The ratio of final size to smallest possible size
backgroundColor
Background color of the QR code, defaults to white.
foregroundColor
Foreground color for code points, defaults to black.
watermark
The data of background GIF to use.
watermarkMode
How to position the
watermark
, defaults to aspect fill.isWatermarkTransparent
Wether to use the alpha channel in watermark image.
icon
The icon that appears in the center of QR code image, if any.
iconSize
Size of the
icon
, defaults to 20% ofsize
.pointStyle
Foreground code point style, defaults to square.
pointOffset
How much are foreground points shifted.
isTimingPointStyled
Wether the timing points should be styled (or remain square).
mode
The color rendering mode, defaults to original colors.
Return Value
The generated QR code GIF.
-
Generates an animated QR code GIF with a
generator
specifying other parameters.Declaration
Swift
public static func generateGIF(using generator: EFQRCodeGenerator, withWatermarkGIF data: Data, delay: Double? = nil, loopCount: Int? = nil, useMultipleThreads: Bool = false) -> Data?
Parameters
generator
An
EFQRCodeGenerator
providing other QR code generation settings.data
The data of the watermark GIF.
delay
Output QRCode GIF delay, emitted means no change.
loopCount
Times looped in GIF, emitted means no change.
useMultipleThreads
Wether to use multiple threads for better performance, defaults to
false
.Return Value
The generated QR code GIF.