iOS 二维码的制作(libqrencode)

来源:互联网 发布:开淘宝网店步骤 编辑:程序博客网 时间:2024/05/22 17:40

首先下载一个别人写好的libqrencode,下载来后是这样的:



把这个文件拖到我们的工程里面,记得在QRCodeGenerator.h中导入#import<UIKit/UIKit.h>框架


代码实现:(在ViewController。h中导入#import"QRCodeGenerator.h"

<span style="color:#666666;">    imageView = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, 150, 150)];    imageView.center = self.view.center;    imageView.backgroundColor = [UIColor greenColor];        [self.view addSubview:imageView];   </span><span style="color:#ff0000;"> UIImage *image = [QRCodeGenerator qrImageForString:@"www.baidu.com" imageSize:imageView.bounds.size.width];</span><span style="color:#33cc00;">//核心代码</span><span style="color:#666666;">    imageView.image = image;</span>


在核心代码中的字符串,我们可以设置网页、图片或者文本等等,我们在这里是使用百度的网址来代替的







0 0
原创粉丝点击