/**
* 生成二维码
*
* @param code
* @param width
* @param height
*
* @return
*/
+ (UIImage *)generateBarCode:(NSString *)code width:(CGFloat)width height:(CGFloat)height fileName:(NSString *)fileName{
CIImage *qrcodeImage;
NSData *data = [code dataUsingEncoding:NSISOLatin1StringEncoding allowLossyConversion:false];
CIFilter *filter = [CIFilter filterWithName:@"CIQRCodeGenerator"];
[filter setValue:data forKey:@"inputMessage"];
[filter setValue:@"H" forKey:@"inputCorrectionLevel"];
qrcodeImage = [filter outputImage];
// 消除模糊
CGFloat scaleX = width / qrcodeImage.extent.size.width; // extent 返回图片的frame
CGFloat scaleY = height / qrcodeImage.extent.size.height;
CIImage *transformedImage = [qrcodeImage imageByApplyingTransform:CGAffineTransformScale(CGAffineTransformIdentity, scaleX, scaleY)];
return [UIImage imageWithCIImage:transformedImage];
}