首页 > 其他 > 详细

使用QRCode简单生成二维码

时间:2016-09-06 22:42:12      阅读:170      评论:0      收藏:0      [点我收藏+]

//

//  ViewController.m

//  二维码

//

//  Created by 123 on 16/9/4.

//  Copyright © 2016 彭洪. All rights reserved.

//

 

#import "ViewController.h"

#import "QRCodeGenerator.h"//引入库

@interface ViewController ()

 

@end

 

@implementation ViewController

 

- (void)viewDidLoad {

    [super viewDidLoad];

    self.view.backgroundColor = [UIColor whiteColor];

    [self initQRCode];

}

 

- (void)initQRCode {

    CGFloat w = [UIScreen mainScreen].bounds.size.width;

    NSArray *arr = @[[QRCodeGenerator qrImageForString:@"Key" imageSize:400],

                     [QRCodeGenerator qrImageForString:@"Key1" imageSize:400 Topimg:[UIImage imageNamed:@"super.jpg"]],

                     [QRCodeGenerator qrImageForString:@"Key3" imageSize:400 withPointType:QRPointRound withPositionType:QRPositionRound withColor:[UIColor redColor]]

                     ];

    for (int i=0; i<3; i++) {

        UIImageView *qr = [[UIImageView alloc] initWithFrame:CGRectMake((i%3)*w/3, 100+(i/3)*w/3, w/3, w/3)];

        qr.image = arr[i];

        [self.view addSubview:qr];

    }

}

 

- (void)didReceiveMemoryWarning {

    [super didReceiveMemoryWarning];

    // Dispose of any resources that can be recreated.

}

 

@end

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 技术分享

使用QRCode简单生成二维码

原文:http://www.cnblogs.com/PengHongMiao/p/5847296.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!