// // KDPPasteView.m // KuDianProject // // Created by 学丽 on 2019/7/11. // Copyright © 2019 KDP. All rights reserved. // #import "KDPPasteView.h" @implementation KDPPasteView -(instancetype)initWithFrame:(CGRect)frame { self=[super initWithFrame:frame]; if (self) { self.backgroundColor=[UIColor colorWithRed:0/255.0 green:0/255.0 blue:0/255.0 alpha:0.4]; UIView *backV=[[UIView alloc]initWithFrame:CGRectMake(0, 0, 281, 285)]; backV.backgroundColor=[UIColor whiteColor]; backV.layer.cornerRadius=9; backV.layer.masksToBounds=YES; [self addSubview:backV]; backV.center=self.center; UIImageView *imgv=[[UIImageView alloc]initWithFrame:CGRectMake(59, 39, 34, 34)]; imgv.image=[UIImage imageNamed:@"paste_icon"]; [backV addSubview:imgv]; UILabel *label =[[UILabel alloc]initWithFrame:CGRectMake(imgv.right+9, 39, 150, 34)]; label.text=@"淘口令已复制"; label.textColor=[UIColor colorWithHexString:ThemeColor]; label.font=[UIFont systemFontOfSize:20]; [backV addSubview:label]; self.pasteLabel=[[UILabel alloc]initWithFrame:CGRectMake(26, imgv.bottom+24, 229, 52)]; self.pasteLabel.font=[UIFont systemFontOfSize:15]; self.pasteLabel.numberOfLines=2; self.pasteLabel.textAlignment=NSTextAlignmentCenter; self.pasteLabel.textColor=[UIColor colorWithHexString:fontColor]; [backV addSubview:self.pasteLabel]; UIButton *buyButton=[[UIButton alloc]initWithFrame:CGRectMake(26, self.pasteLabel.bottom+30, 230, 43)]; buyButton.layer.cornerRadius=21.5; buyButton.layer.masksToBounds=YES; [backV addSubview:buyButton]; buyButton.backgroundColor=[UIColor colorWithHexString:ThemeColor]; buyButton.titleLabel.font=[UIFont systemFontOfSize:14]; [buyButton setTitle:@"打开淘宝购买" forState:UIControlStateNormal]; [backV addSubview:buyButton]; [buyButton addTarget:self action:@selector(clickTBBtuuton) forControlEvents:UIControlEventTouchUpInside]; UIButton *kwaiBtn=[[UIButton alloc]initWithFrame:CGRectMake(26, buyButton.bottom+10, 230, 38)]; [kwaiBtn setTitle:@"推广到快手" forState:UIControlStateNormal]; kwaiBtn.titleLabel.font=[UIFont systemFontOfSize:14]; [kwaiBtn setTitleColor:[UIColor colorWithHexString:@"#666666"] forState:UIControlStateNormal]; [backV addSubview:kwaiBtn]; [kwaiBtn addTarget:self action:@selector(clickKwaiButton) forControlEvents:UIControlEventTouchUpInside]; } return self; } #pragma mark---t打开淘宝 -(void)clickTBBtuuton { if (![KDPublicMethod JumpOpenURL:@"taobao://"]) { [MBProgressHUD showError:TBMessage]; return; } UIPasteboard * pastboard = [UIPasteboard generalPasteboard]; if (self.tkl.length<=0) { return; } pastboard.string=_tkl; [self clickWithURI:@"taobao://"]; } #pragma mark---推广到快手 -(void)clickKwaiButton { if (![KDPublicMethod JumpOpenURL:KWai]) { [MBProgressHUD showError:KWaiMessage]; return; } [self clickWithURI:KWai]; } -(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { self.hidden=YES; } -(void)clickWithURI:(NSString *)jumpurl { self.hidden=YES; NSString* taobao = [NSString stringWithFormat:@"%@", jumpurl]; UIWebView* webview = [[UIWebView alloc]initWithFrame:CGRectZero]; [[UIApplication sharedApplication].keyWindow addSubview:webview]; NSURL*url = [NSURL URLWithString:taobao]; NSURLRequest *request = [NSURLRequest requestWithURL:url]; [webview loadRequest:request]; } @end