Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save jensmeder/6fde97504d660abc6de56edac735187a to your computer and use it in GitHub Desktop.
Save jensmeder/6fde97504d660abc6de56edac735187a to your computer and use it in GitHub Desktop.
Generating QR Codes with Core Image
import Foundation
import UIKit
import PlaygroundSupport
let data = "Hello World!".data(using: .utf8)!
let filter = CIFilter(name: "CIQRCodeGenerator", withInputParameters: ["inputMessage" : data, "inputCorrectionLevel":"L"])
let ciimage = filter!.outputImage!
let transform = CGAffineTransform(scaleX: 7.0, y: 7.0)
let image = ciimage.applying(transform)
let img = UIImage(ciImage: image)
PlaygroundPage.current.liveView = UIImageView(image: img)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment