123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263 |
- //
- // MyQRViewController.m
- // LBXScanDemo
- //
- // Created by lbxia on 15/10/21.
- // Copyright © 2015年 lbxia. All rights reserved.
- //
- #import "MyQRViewController.h"
- #import "LBXScanWrapper.h"
- @interface MyQRViewController ()
- //二维码
- @property (nonatomic, strong) UIView *qrView;
- @property (nonatomic, strong) UIImageView* qrImgView;
- @end
- @implementation MyQRViewController
- - (void)viewDidLoad {
- [super viewDidLoad];
- // Do any additional setup after loading the view.
-
- if ([self respondsToSelector:@selector(setEdgesForExtendedLayout:)]) {
-
- self.edgesForExtendedLayout = UIRectEdgeNone;
- }
-
- self.view.backgroundColor = [UIColor whiteColor];
- }
- - (void)viewDidAppear:(BOOL)animated
- {
- [super viewDidAppear:animated];
-
- //二维码
- UIView *view = [[UIView alloc]initWithFrame:CGRectMake( (CGRectGetWidth(self.view.frame)-CGRectGetWidth(self.view.frame)*5/6)/2, 100, CGRectGetWidth(self.view.frame)*5/6, CGRectGetWidth(self.view.frame)*5/6)];
- [self.view addSubview:view];
- view.backgroundColor = [UIColor whiteColor];
- view.layer.shadowOffset = CGSizeMake(0, 2);
- view.layer.shadowRadius = 2;
- view.layer.shadowColor = [UIColor blackColor].CGColor;
- view.layer.shadowOpacity = 0.5;
-
- self.qrImgView = [[UIImageView alloc]init];
- _qrImgView.bounds = CGRectMake(0, 0, CGRectGetWidth(view.frame)-12, CGRectGetWidth(view.frame)-12);
- _qrImgView.center = CGPointMake(CGRectGetWidth(view.frame)/2, CGRectGetHeight(view.frame)/2);
- [view addSubview:_qrImgView];
- self.qrView = view;
- UIImage *qrImg = [LBXScanWrapper createQRWithString:@"www.baidu.com" size:_qrImgView.bounds.size];
-
- UIImage *logoImg = [UIImage imageNamed:@"logo.JPG"];
- _qrImgView.image = [LBXScanWrapper addImageLogo:qrImg centerLogoImage:logoImg logoSize:CGSizeMake(30, 30)];
-
- }
- @end
|