手順
これをコピペ
extension String {
func generateQR() -> UIImage? {
guard let data = self.data(using: .utf8) else { return nil }
guard let qr = CIFilter(name: "CIQRCodeGenerator", parameters: ["inputMessage": data, "inputCorrectionLevel": "M"]) else { return nil }
let sizeTransform = CGAffineTransform(scaleX: 10, y: 10)
guard let qrImage = qr.outputImage?.transformed(by: sizeTransform) else { return nil }
return UIImage(ciImage: qrImage)
}
}
したらこう使う
imageView.image = "https://github.com/son".generateQR()

やったね!