// // ShareViewController.m // KeleAppProject // // Created by 熊竹 on 2018/3/5. // Copyright © 2018年 Cen Zhou. All rights reserved. // #import "SharePopViewController.h" #import @interface SharePopViewController () @property(weak, nonatomic) IBOutlet UIView *contentView; @property(weak, nonatomic) IBOutlet UIImageView *shareWechat; @property(weak, nonatomic) IBOutlet UIImageView *shareTimeline; @end @implementation SharePopViewController - (instancetype)init { self = [super init]; if (self) { self.modalPresentationStyle = UIModalPresentationOverCurrentContext; self.view.backgroundColor = [UIColor colorWithRed:0 green:0 blue:0 alpha:0]; self.view.userInteractionEnabled = YES; } return self; } - (instancetype)initWithCoder:(NSCoder *)coder { self = [super initWithCoder:coder]; if (self) { self.modalPresentationStyle = UIModalPresentationOverCurrentContext; self.view.backgroundColor = [UIColor colorWithRed:0 green:0 blue:0 alpha:0]; self.view.userInteractionEnabled = YES; } return self; } - (void)viewDidLoad { [super viewDidLoad]; self.contentView.transform = CGAffineTransformMakeTranslation(0, 164); self.shareWechat.userInteractionEnabled = YES; self.shareTimeline.userInteractionEnabled = YES; } - (void)viewWillAppear:(BOOL)animated { [super viewWillAppear:animated]; [UIView animateWithDuration:0.2 delay:0 options:UIViewAnimationOptionCurveEaseOut animations:^{ self.contentView.transform = CGAffineTransformMakeTranslation(0, 0); self.view.backgroundColor = [UIColor colorWithRed:0 green:0 blue:0 alpha:0.2]; } completion:nil]; } - (IBAction)cancel:(id)sender { [self dismiss]; } - (IBAction)tapItem:(id)sender { if (((UITapGestureRecognizer *) sender).view.tag == 1) { [self shareToWechat:WXSceneSession withTitle:@"千模" description:@"千模" url:shareUrl(@(self.type), [[NSUserDefaults standardUserDefaults] objectForKey:@"qrcode"])]; } else if (((UITapGestureRecognizer *) sender).view.tag == 2) { [self shareToWechat:WXSceneTimeline withTitle:@"千模" description:@"千模" url:shareUrl(@(self.type), [[NSUserDefaults standardUserDefaults] objectForKey:@"qrcode"])]; } [self dismiss]; } - (void)dismiss { [UIView animateWithDuration:0.2 delay:0 options:UIViewAnimationOptionCurveEaseInOut animations:^{ self.contentView.transform = CGAffineTransformMakeTranslation(0, 164); self.view.backgroundColor = [UIColor colorWithRed:0 green:0 blue:0 alpha:0]; } completion:^(BOOL finished) { [self dismissViewControllerAnimated:NO completion:nil]; }]; } - (void)shareToWechat:(enum WXScene)scene withTitle:(NSString *)title description:(NSString *)description url:(NSString *)url { SendMessageToWXReq *req = [[SendMessageToWXReq alloc] init]; req.bText = NO; req.scene = scene; WXMediaMessage *urlMessage = [WXMediaMessage message]; urlMessage.title = title; urlMessage.description = description; [urlMessage setThumbImage:[UIImage imageNamed:@"AppIcon"]]; WXWebpageObject *webObj = [WXWebpageObject object]; webObj.webpageUrl = url; urlMessage.mediaObject = webObj; req.message = urlMessage; [WXApi sendReq:req]; } /* #pragma mark - Navigation // In a storyboard-based application, you will often want to do a little preparation before navigation - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { // Get the new view controller using [segue destinationViewController]. // Pass the selected object to the new view controller. } */ @end