酷店

KDPPasteView.m 3.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. //
  2. // KDPPasteView.m
  3. // KuDianProject
  4. //
  5. // Created by 学丽 on 2019/7/11.
  6. // Copyright © 2019 KDP. All rights reserved.
  7. //
  8. #import "KDPPasteView.h"
  9. @implementation KDPPasteView
  10. -(instancetype)initWithFrame:(CGRect)frame
  11. {
  12. self=[super initWithFrame:frame];
  13. if (self) {
  14. self.backgroundColor=[UIColor colorWithRed:0/255.0 green:0/255.0 blue:0/255.0 alpha:0.4];
  15. UIView *backV=[[UIView alloc]initWithFrame:CGRectMake(0, 0, 281, 285)];
  16. backV.backgroundColor=[UIColor whiteColor];
  17. backV.layer.cornerRadius=9;
  18. backV.layer.masksToBounds=YES;
  19. [self addSubview:backV];
  20. backV.center=self.center;
  21. UIImageView *imgv=[[UIImageView alloc]initWithFrame:CGRectMake(59, 39, 34, 34)];
  22. imgv.image=[UIImage imageNamed:@"paste_icon"];
  23. [backV addSubview:imgv];
  24. UILabel *label =[[UILabel alloc]initWithFrame:CGRectMake(imgv.right+9, 39, 150, 34)];
  25. label.text=@"淘口令已复制";
  26. label.textColor=[UIColor colorWithHexString:ThemeColor];
  27. label.font=[UIFont systemFontOfSize:20];
  28. [backV addSubview:label];
  29. self.pasteLabel=[[UILabel alloc]initWithFrame:CGRectMake(26, imgv.bottom+24, 229, 52)];
  30. self.pasteLabel.font=[UIFont systemFontOfSize:15];
  31. self.pasteLabel.numberOfLines=2;
  32. self.pasteLabel.textAlignment=NSTextAlignmentCenter;
  33. self.pasteLabel.textColor=[UIColor colorWithHexString:fontColor];
  34. [backV addSubview:self.pasteLabel];
  35. UIButton *buyButton=[[UIButton alloc]initWithFrame:CGRectMake(26, self.pasteLabel.bottom+30, 230, 43)];
  36. buyButton.layer.cornerRadius=21.5;
  37. buyButton.layer.masksToBounds=YES;
  38. [backV addSubview:buyButton];
  39. buyButton.backgroundColor=[UIColor colorWithHexString:ThemeColor];
  40. buyButton.titleLabel.font=[UIFont systemFontOfSize:14];
  41. [buyButton setTitle:@"打开淘宝购买" forState:UIControlStateNormal];
  42. [backV addSubview:buyButton];
  43. [buyButton addTarget:self action:@selector(clickTBBtuuton) forControlEvents:UIControlEventTouchUpInside];
  44. UIButton *kwaiBtn=[[UIButton alloc]initWithFrame:CGRectMake(26, buyButton.bottom+10, 230, 38)];
  45. [kwaiBtn setTitle:@"推广到快手" forState:UIControlStateNormal];
  46. kwaiBtn.titleLabel.font=[UIFont systemFontOfSize:14];
  47. [kwaiBtn setTitleColor:[UIColor colorWithHexString:@"#666666"] forState:UIControlStateNormal];
  48. [backV addSubview:kwaiBtn];
  49. [kwaiBtn addTarget:self action:@selector(clickKwaiButton) forControlEvents:UIControlEventTouchUpInside];
  50. }
  51. return self;
  52. }
  53. #pragma mark---t打开淘宝
  54. -(void)clickTBBtuuton
  55. {
  56. if (![KDPublicMethod JumpOpenURL:@"taobao://"]) {
  57. [MBProgressHUD showError:TBMessage];
  58. return;
  59. }
  60. UIPasteboard * pastboard = [UIPasteboard generalPasteboard];
  61. if (self.tkl.length<=0) {
  62. return;
  63. }
  64. pastboard.string=_tkl;
  65. [self clickWithURI:@"taobao://"];
  66. }
  67. #pragma mark---推广到快手
  68. -(void)clickKwaiButton
  69. {
  70. if (![KDPublicMethod JumpOpenURL:KWai]) {
  71. [MBProgressHUD showError:KWaiMessage];
  72. return;
  73. }
  74. [self clickWithURI:KWai];
  75. }
  76. -(void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event
  77. {
  78. self.hidden=YES;
  79. }
  80. -(void)clickWithURI:(NSString *)jumpurl
  81. {
  82. self.hidden=YES;
  83. NSString* taobao = [NSString stringWithFormat:@"%@", jumpurl];
  84. UIWebView* webview = [[UIWebView alloc]initWithFrame:CGRectZero];
  85. [[UIApplication sharedApplication].keyWindow addSubview:webview];
  86. NSURL*url = [NSURL URLWithString:taobao];
  87. NSURLRequest *request = [NSURLRequest requestWithURL:url];
  88. [webview loadRequest:request];
  89. }
  90. @end