iOS 二维码的生成 QREncoder

  

生成二维码:

 

在生成二维码的库中QREncoder最为常见,但是由于中文字符的特殊性,生成中文的时候有时会出现一定的错误,所以建议使用libqrencode,是一个纯C编写的类库.

 

以libqrencode为例:

libqrencode官网:http://fukuchi.org/works/qrencode/index.html.en

github地址:https://github.com/fukuchi/libqrencode

不过该工程没有针对iOS提供字符串转换为图像的代码,网络上有人新增了QRCodeGenerator类,针对iOS优化.

下载地址:http://download.csdn.net/download/sjx19871225/5065683

 

使用:

libqrencode加入到工程中,在需要用到的地方引入"QRCodeGenerator.h"

imageView为界面需要显示二维码的UIImageView;

resultString为需要生成二维码的字符串;

imageView.image = [QRCodeGenerator qrImageForString:resultString imageSize:self.imageView.frame.size.height];

posted @ 2015-11-12 15:40  jgCho  阅读(800)  评论(0编辑  收藏  举报