省钱达人

MyQRViewController.m 1.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. //
  2. // MyQRViewController.m
  3. // LBXScanDemo
  4. //
  5. // Created by lbxia on 15/10/21.
  6. // Copyright © 2015年 lbxia. All rights reserved.
  7. //
  8. #import "MyQRViewController.h"
  9. #import "LBXScanWrapper.h"
  10. @interface MyQRViewController ()
  11. //二维码
  12. @property (nonatomic, strong) UIView *qrView;
  13. @property (nonatomic, strong) UIImageView* qrImgView;
  14. @end
  15. @implementation MyQRViewController
  16. - (void)viewDidLoad {
  17. [super viewDidLoad];
  18. // Do any additional setup after loading the view.
  19. if ([self respondsToSelector:@selector(setEdgesForExtendedLayout:)]) {
  20. self.edgesForExtendedLayout = UIRectEdgeNone;
  21. }
  22. self.view.backgroundColor = [UIColor whiteColor];
  23. }
  24. - (void)viewDidAppear:(BOOL)animated
  25. {
  26. [super viewDidAppear:animated];
  27. //二维码
  28. 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)];
  29. [self.view addSubview:view];
  30. view.backgroundColor = [UIColor whiteColor];
  31. view.layer.shadowOffset = CGSizeMake(0, 2);
  32. view.layer.shadowRadius = 2;
  33. view.layer.shadowColor = [UIColor blackColor].CGColor;
  34. view.layer.shadowOpacity = 0.5;
  35. self.qrImgView = [[UIImageView alloc]init];
  36. _qrImgView.bounds = CGRectMake(0, 0, CGRectGetWidth(view.frame)-12, CGRectGetWidth(view.frame)-12);
  37. _qrImgView.center = CGPointMake(CGRectGetWidth(view.frame)/2, CGRectGetHeight(view.frame)/2);
  38. [view addSubview:_qrImgView];
  39. self.qrView = view;
  40. UIImage *qrImg = [LBXScanWrapper createQRWithString:@"www.baidu.com" size:_qrImgView.bounds.size];
  41. UIImage *logoImg = [UIImage imageNamed:@"logo.JPG"];
  42. _qrImgView.image = [LBXScanWrapper addImageLogo:qrImg centerLogoImage:logoImg logoSize:CGSizeMake(30, 30)];
  43. }
  44. @end