Cat Share, must boutique
Original articles, welcome reprint. Reprint Please specify: Sanayu's Blog
Address: http://blog.csdn.net/u013357243
QR Code is a project may be used, iOS open camera request QR Code speed is not Android can compare ... (Android scan QR code to swing back and forth ...) )
Simple to say, how to put a piece of information (URL, string) into a QR code, directly on the code
Steps:
Import Coreimage Framework #import <CoreImage/CoreImage.h>
Generate two-dimensional code with filter Cifilter
#import "ViewController.h" #import <CoreImage/CoreImage.h> @interface viewcontroller ()@property(Weak,nonatomic)Iboutlet Uiimageview*iv;@end @implementation viewcontroller - (void) Touchesbegan: (Nsset *) touches withevent: (uievent *) event{//1. Instantiate a QR Code filterCifilter *filter = [Cifilter filterwithname:@"Ciqrcodegenerator"];//2. Restore the default properties of the filter (because the filter might have saved the last property)[Filter SetDefaults];//3. Convert String to NSDataNSData *data = [@"Http://www.itheima.com"Datausingencoding:nsutf8stringencoding];//4. Set the filter via KVO, pass in data, and future filters will know to generate a QR code from the incoming[Filter Setvalue:data forkey:@"InputMessage"];//5. Generate two-dimensional codeCiimage *outputimage = [Filter outputimage];UIImage*image = [UIImageImagewithciimage:outputimage];//6. Set the generated QR code to ImageView Self. IV. Image= Image;}@end
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
Cat learns the QR code of iOS and quickly generates two-dimensional code