ABC-abc-1234
ABC-abc-1234
func generateBarcode(from string: String) -> UIImage? { let data = string.data(using: .ascii) if let filter = CIFilter(name: "CICode128BarcodeGenerator") { filter.setValue(data, forKey: "inputMessage") if let outputImage = filter.outputImage { // Scale the image to a suitable resolution let transform = CGAffineTransform(scaleX: 10, y: 10) // Adjust the scale as needed let scaledImage = outputImage.transformed(by: transform) let context = CIContext() if let cgImage = context.createCGImage(scaledImage, from: scaledImage.extent) { return UIImage(cgImage: cgImage) } } } return nil }
Не видишь разницы?
Обсуждают сегодня