苹果系统自带的二维码生成和扫描

- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event

{

/**  1 实例化二维码滤镜  */


CIFilter * filter = [CIFilter filterWithName:@"CIQRCodeGenerator"];
/**  2 恢复滤镜默认设置  */

[filter setDefaults];

/**  3 设置二维码内容  */
NSData *data = [@"http://www.baidu.com" dataUsingEncoding:NSUTF8StringEncoding];

[filter setValue:data forKey:@"inputMessage"];

CIImage * outputImage = [filter outputImage];
/** 4 显示二维码  */
self.coreImage.image = [UIImage imageWithCIImage:outputImage];

}

你可能感兴趣的:(苹果系统自带的二维码生成和扫描)