Hi All,
I am developing an IOS app using Swift and Firebase. I want to generate a Barcode for each user and provide discounts to them. How can I generate a Barcode? Which Barcode scanning device is suitable?
I have googled and read, but they are not useful. Please shed some light and provide any useful link or website.
I have tried below code, but it's not generating an Barcode. I don't see any output/Barcode image. My screen was empty. Please suggest.
@IBAction func gen(_ sender: UIButton) { imageDisplay.image = generateBarcodeFromString(from: tfInput.text!) }
func generateBarcodeFromString(from string: String)-> UIImage?{ let data = string.data(using: String.Encoding.ascii) let filter = CIFilter(name: "CICode128BarcodeGenerator") filter?.setValue(data, forKey: "inputMessage") let transform = __CGAffineTransformMake(10, 10, 10, 10, 10, 10) / CGAffineTransform(scaleX: 3, y: 3)
*/
if let output = filter?.outputImage?.applying(transform){ return UIImage(ciImage: output) } return nil }