code128BarcodeGenerator()
Generates a high-density, linear barcode.
Declaration
class func code128BarcodeGenerator() -> any CIFilter & CICode128BarcodeGeneratorReturn Value
The generated image.
Discussion
This method generates a Code 128 barcode as an image. Code 128 is a high-density linear barcode defined in the ISO/IEC 15417:2007 standard. Use this filter to generate alphanumeric or numeric-only barcodes. The barcode can contain any of the 128 ASCII characters.
The Code 128 barcode filter uses the following properties:
messageNSData containing the message to encode in the Code 128 barcode.
quietSpaceNSNumber containing the number of empty white pixels that should surround the barcode.
barcodeHeightNSNumber containing the height of the generated barcode in pixels.
The following code creates a filter that generates a Code 128 barcode:
func code128Barcode(barcode: String) -> CIImage {
let code128Barcode = CIFilter.code128BarcodeGenerator()
code128Barcode.message = barcode.data(using: .ascii)!
code128Barcode.quietSpace = 5
code128Barcode.barcodeHeight = 20
return code128Barcode.outputImage!
}[Image]
See Also
Filters
attributedTextImageGenerator()aztecCodeGenerator()barcodeGenerator()blurredRectangleGenerator()checkerboardGenerator()lenticularHaloGenerator()meshGenerator()pdf417BarcodeGenerator()qrCodeGenerator()randomGenerator()roundedRectangleGenerator()roundedRectangleStrokeGenerator()starShineGenerator()stripesGenerator()sunbeamsGenerator()