>  iOS >  상세

Swift QRcode make


목록:iOS    TAG: swift , qrcode     등록일:2018-10-15    조횟수:

Swift QR코드 생성

QR코드 생성하는 방법을 찾아보다가 알아낸 Swift로 QR코드 생성하기.

iOS에서는 자체 라이브러리로 자기가원하는 텍스트를 가지고 QR코드를 생성할 수 있다.

아래 예제 소스로 확인하기 바란다.

func qrCodeMake(text: String) -> UIImage? {
    guard let filter = CIFilter(name: "CIQRCodeGenerator") else { return nil }
	let stringData = text.data(using: String.Encoding.utf8)
    
  	filter.setValue(stringData, forkey: "inputMessage")
	filter.setValue("H", forKey: "inputCorrectionLevel")
        
    if let outout = filter.outputImage {
        return UIImage(ciImage: outout, scale: 1.0, orientation: UIImageOrientation.down)
    } else {
        return nil
    }
}
이 기사는 원본 기사입니다. 소스를 지정하십시오.:Kodaewon's Blog » Swift QRcode make

이전: Swift Optionals