//MARK:- generate QR codefunc generateQRImage(stringQR:Nsstring,withSizeRate rate:CGfloat) -> UIImage{ var filter:CIFilter = CIFilter(name:"CiqrCodeGenerator") filter.setDefaults() var data:NSData = stringQR.dataUsingEnCoding(NSUTF8StringEnCoding)! filter.setValue(data,forKey: "inputMessage") var outputimg:CIImage = filter.outputimage var context:CIContext = CIContext(options: nil) var cgimg:CGImageRef = context.createCGImage(outputimg,fromrect: outputimg.extent()) var img:UIImage = UIImage(CGImage: cgimg,scale: 1.0,orIEntation: UIImageOrIEntation.Up)! var wIDth = img.size.wIDth * rate var height = img.size.height * rate UIGraphicsBeginImageContext(CGSizeMake(wIDth,height)) var cgContxt:CGContextRef = UIGraphicsGetCurrentContext() CGContextSetInterpolationQuality(cgContxt,kCGInterpolationNone) img.drawInRect(CGRectMake(0,wIDth,height)) img = UIGraphicsGetimageFromCurrentimageContext() UIGraphicsEndImageContext() return img}总结
以上是内存溢出为你收集整理的Swift中的QR码阅读器和发生器全部内容,希望文章能够帮你解决Swift中的QR码阅读器和发生器所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)