生成Code 39条形码

问题描述 投票:2回答:1

我有这个代码来生成条形码:

func generateBarcode(from string: String) -> UIImage?
{
    let data = string.data(using: String.Encoding.ascii)
    if let filter = CIFilter(name: "CICode128BarcodeGenerator")
    {
        filter.setValue(data, forKey: "inputMessage")
        let transform = CGAffineTransform(scaleX: 3, y: 3)
        if let output = filter.outputImage?.transformed(by: transform)
        {
            return UIImage(ciImage: output)
        }
    }
    return nil
}

我需要生成一个code39条形码。我还没有为Code 39找到“CICode128BarcodeGenerator”的等价物。

如何为代码39修改此代码?

谢谢

ios swift barcode-printing code39
1个回答
1
投票

如果我正确读取Apple Documentation这些是他们编码的类型:

Aztec
CheckerBoard
Code128
ConstantColor
LenticularHalo
PDF417Barcode
Random
Starshine
Stripes
Sunbeams
© www.soinside.com 2019 - 2024. All rights reserved.