Created
March 13, 2016 07:37
-
-
Save matsuhisa/71e8e6ad7d1edef70650 to your computer and use it in GitHub Desktop.
SwiftでQRコードを生成してみた ref: http://qiita.com/matsuhisa_h/items/91cdeeaf32553c3b23fb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import UIKit | |
import CoreImage | |
var url = "http://www.yahoo.co.jp/" | |
// NSString から NSDataへ変換 | |
let data = url.dataUsingEncoding(NSUTF8StringEncoding)! | |
// QRコード生成のフィルター | |
// NSData型でデーターを用意 | |
// inputCorrectionLevelは、誤り訂正レベル | |
let qr = CIFilter(name: "CIQRCodeGenerator", withInputParameters: ["inputMessage": data, "inputCorrectionLevel": "M"])! | |
let sizeTransform = CGAffineTransformMakeScale(10, 10) | |
let qrImage = qr.outputImage!.imageByApplyingTransform(sizeTransform) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment