Oc 二维码的生成

本篇讲解如何生成二维码.我们生成二维码要先导入libqrencode第三方

1.制作二维码/*字符转二维码

导入 libqrencode文件

添加#import "QRCodeGenerator.h"

#import "QRCodeGenerator.h"

@interface ViewController ()
@property (strong , nonatomic) UIImageView* qRImageView;
@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
    self.qRImageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 320, 400)];
    [self.view addSubview:self.qRImageView];
    
    UIButton *button = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    button.frame = CGRectMake(100, 200, 100, 50);
    [button setTitle:@"扫描" forState:UIControlStateNormal];
    [button addTarget:self action:@selector(click) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:button];
}

- (void)click
{
    self.qRImageView.image = [QRCodeGenerator qrImageForString:@"二维码存储的字符串信息 asddsdd" imageSize:self.qRImageView.bounds.size.width];
}

你可能感兴趣的:(Oc 二维码的生成)