Cat learns the QR code of iOS and quickly generates two-dimensional code

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.