123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778 |
- //
- // MyQRCodeVC.m
- // smartRhino
- //
- // Created by armin on 2019/11/1.
- // Copyright © 2019 tederen. All rights reserved.
- //
- #import "MyQRCodeVC.h"
- #import <Photos/Photos.h>
- #import "CreateNoteBookVC.h"
- @interface MyQRCodeVC ()
- @property (strong,nonatomic) IBOutlet UIView *showContentBgView;
- @property (strong,nonatomic) IBOutlet UIButton *shareBtn;
- @property (strong,nonatomic) IBOutlet UIImageView *qrCodeImg;
- @end
- @implementation MyQRCodeVC
- +(MyQRCodeVC *)initMyQRCodeVC{
- MyQRCodeVC *controller = [StoryboardManager.shared.myCenter instantiateViewControllerWithIdentifier:@"MyQRCodeVC"];
- return controller;
- }
- - (void)viewDidLoad {
- [super viewDidLoad];
- self.fd_prefersNavigationBarHidden = YES;
- self.view.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.3f];
- UITapGestureRecognizer *gr = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(dismiss)];
- self.view.userInteractionEnabled = YES;
- [gr setNumberOfTapsRequired:1];
- [self.view addGestureRecognizer:gr];
-
- self.showContentBgView.layer.masksToBounds = YES;
- self.showContentBgView.layer.cornerRadius = 5.0;
-
- UILongPressGestureRecognizer *longPressGesture =[[UILongPressGestureRecognizer alloc]initWithTarget:self action:@selector(headerLongPress:)];
- [self.showContentBgView addGestureRecognizer:longPressGesture];
-
- WS(weakSelf);
-
- [self.qrCodeImg setImageWithURL:[NSURL URLWithString:[AppUserModel sharedAppUserModel].QRCoder] placeholder:IMG(@"zhujun")];
- [self.shareBtn setAction:^{
- if (weakSelf.ClickShareBlock && weakSelf.qrCodeImg.image) {
- weakSelf.ClickShareBlock(weakSelf.qrCodeImg.image);
- [weakSelf dismiss];
- }
- }];
- }
- - (void)dismiss
- {
- self.view.hidden = YES;
- }
- /**
- * 长按
- */
- -(void)headerLongPress:(UILongPressGestureRecognizer *)longRecognizer{
- if (longRecognizer.state == UIGestureRecognizerStateBegan) {
- WS(weakSelf);
- NSError *error = nil;
- [[PHPhotoLibrary sharedPhotoLibrary] performChangesAndWait:^{
- [PHAssetChangeRequest creationRequestForAssetFromImage:weakSelf.qrCodeImg.image];
- } error:&error];
- if(error){
- [ShowtipTool showMessageWithStatus:@"保存失败"];
- }else{
- [ShowtipTool showMessageWithStatus:@"保存成功"];
- }
- }
- }
- @end
|