iOS 7 after the system for us to integrate the generation of two-dimensional code and read function, we can use the system comes with the framework of the two-dimensional code related operations. Frame Coreimage Frame (the frame can do the frosted glass effect), through the filter cifilter generate two-dimensional code.
Generate QR Code step: Include Vault header file Import <CoreImage/coreImage.h>
1, create filter
Cifilter *filter = [Cifilter filterwithname:@ "Ciqrcodegenerator"];
2, restore default settings
[Filter SetDefaults];
3. Add data to the filter
NSString *str = @"这是一个二维码的生成结果"; (如果想让二维码是一个URL,直接将字符串改成URL地址)
NSData *data = [str datausingencoding:nsutf8stringencoding];
[filter setValue:data forKey:@"inputMessage"];
4, get the output of the QR code
Ciimage *outputimage = [Filter outputimage]; The return is a ciimage
5, display two-dimensional code
Self.imageView.image = [UIImage imagewithciimage:outputimage]; Added to the UI control.
How iOS generates two-dimensional code