How iOS generates two-dimensional code

Source: Internet
Author: User

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

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.