Is there a way to generate QR code image on iOS

2020-05-12 00:49发布

Is there a standard way to generate a QR code and attach it to a mail item from iOS client app (no server code)?

标签: ios qr-code
9条回答
混吃等死
2楼-- · 2020-05-12 01:46

If you don't mind using public api, here is an easy 10 seconds method. http://goqr.me/api

Just fill in the data parameter, and load the image from the response. Cheers.

查看更多
Bombasti
3楼-- · 2020-05-12 01:51

Code to generate QR image in Swift 2.0.

let reqStr = “string to convert as QR code”
let data = reqStr.dataUsingEncoding(NSISOLatin1StringEncoding, allowLossyConversion: false)

let filter = CIFilter(name: "CIQRCodeGenerator")
filter!.setValue(data, forKey: "inputMessage")

let qrImage:CIImage = filter!.outputImage!

//qrImageView is a IBOutlet of UIImageView        
let scaleX = qrImageView.frame.size.width / qrImage.extent.size.width
let scaleY = qrImageView.frame.size.height / qrImage.extent.size.height

let resultQrImage = qrImage.imageByApplyingTransform(CGAffineTransformMakeScale(scaleX, scaleY))
qrImageView.image = UIImage(CIImage: resultQrImage)
查看更多
走好不送
4楼-- · 2020-05-12 01:53

I have used the QR Code Encoder for QR generation. It is very easy to use. There are some other option to generate, e.g this.

查看更多
登录 后发表回答