USBInsertPopView.m 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198
  1. //
  2. // USBInsertPopView.m
  3. // 隐私保护
  4. //
  5. // Created by xd h on 2024/1/29.
  6. //
  7. #import "USBInsertPopView.h"
  8. #import <Lottie/Lottie.h>
  9. @interface USBInsertPopView ()
  10. @property (nonatomic,strong) UIView* whiteBgView;
  11. @property (nonatomic,copy) NSString* name;
  12. @end
  13. @implementation USBInsertPopView
  14. - (id)initWithFrame:(CGRect)frame withName:(NSString*)name{
  15. self = [super initWithFrame:frame];
  16. self.backgroundColor = [UIColor hwColor:@"000000" alpha:0.6];
  17. _name = name;
  18. [self drawAnyView];
  19. return self;
  20. }
  21. - (void)drawAnyView{
  22. _whiteBgView = [UIView new];
  23. _whiteBgView.layer.cornerRadius = 8;
  24. _whiteBgView.backgroundColor = [UIColor whiteColor];
  25. [self addSubview:_whiteBgView];
  26. [_whiteBgView mas_makeConstraints:^(MASConstraintMaker *make) {
  27. make.height.mas_equalTo(500 + safeArea + 20);
  28. make.left.mas_equalTo(0.f);
  29. make.right.mas_equalTo(0.f);
  30. make.bottom.mas_equalTo(20.f);
  31. }];
  32. NSString *titleRightStr = NSLocalizedString(@"disk_insertion_pop_title",nil);
  33. NSString *curTitleStr = [[NSString alloc] initWithFormat:@"[%@]%@",_name,titleRightStr];
  34. UILabel *titleLab = [[UILabel alloc] init];
  35. titleLab.text = curTitleStr;
  36. titleLab.textAlignment = NSTextAlignmentCenter;
  37. titleLab.numberOfLines = 0;
  38. titleLab.textColor = [UIColor blackColor];
  39. titleLab.font = [UIFont boldSystemFontOfSize:18.0];
  40. [_whiteBgView addSubview:titleLab];
  41. [titleLab mas_makeConstraints:^(MASConstraintMaker *make) {
  42. make.height.mas_equalTo(20);
  43. make.right.mas_equalTo(0.f);
  44. make.left.mas_equalTo(25.f);
  45. make.top.mas_equalTo(20.f);
  46. }];
  47. NSString *curTip1Str = NSLocalizedString(@"disk_insertion_pop_tip",nil);
  48. UILabel *tip1Lab = [[UILabel alloc] init];
  49. tip1Lab.text = curTip1Str;
  50. tip1Lab.numberOfLines = 0;
  51. tip1Lab.textAlignment = NSTextAlignmentCenter;
  52. tip1Lab.textColor = [UIColor hwColor:@"#151515" alpha:0.5];
  53. tip1Lab.font = [UIFont systemFontOfSize:14.0];
  54. [_whiteBgView addSubview:tip1Lab];
  55. CGFloat curHeight = [curTip1Str boundingRectWithSize:CGSizeMake((SCREEN_W - 80), 1000) options:(NSStringDrawingUsesLineFragmentOrigin) attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:14.0]} context:nil].size.height;
  56. curHeight += 15;
  57. [tip1Lab mas_makeConstraints:^(MASConstraintMaker *make) {
  58. make.height.mas_equalTo(curHeight);
  59. make.right.mas_equalTo(-40.f);
  60. make.left.mas_equalTo(40.f);
  61. make.top.mas_equalTo(titleLab.mas_bottom).offset(10.f);
  62. }];
  63. LOTAnimationView *animation = [LOTAnimationView animationNamed:@"usbInsertAnimation"];
  64. animation.loopAnimation = YES;
  65. //animation.contentMode = UIViewContentModeScaleAspectFill;
  66. [_whiteBgView addSubview:animation];
  67. [animation playWithCompletion:^(BOOL animationFinished) {
  68. // Do Something
  69. }];
  70. CGFloat animationImageW = SCREEN_W - 15.0*2;
  71. CGFloat animationImageH = 232.0*animationImageW/343.0;
  72. [animation mas_makeConstraints:^(MASConstraintMaker *make) {
  73. make.height.mas_equalTo(animationImageH);
  74. make.width.mas_equalTo(animationImageW);
  75. make.left.mas_equalTo(15.f);
  76. make.top.mas_equalTo(tip1Lab.mas_bottom).offset(0);
  77. }];
  78. CGFloat imageW = SCREEN_W - 15.0*2;
  79. // CGFloat imageH = 184.0*imageW/343.0;
  80. //
  81. // UIImageView *topImage = [[UIImageView alloc] init];
  82. // topImage.image = [UIImage imageNamed:@"usb_pop_image"];
  83. // [_whiteBgView addSubview:topImage];
  84. //
  85. // [topImage mas_makeConstraints:^(MASConstraintMaker *make) {
  86. // make.height.mas_equalTo(imageH);
  87. // make.width.mas_equalTo(imageW);
  88. // make.left.mas_equalTo(15.f);
  89. // make.top.mas_equalTo(tip1Lab.mas_bottom).offset(20);
  90. // }];
  91. //
  92. // NSString *subTip1 = NSLocalizedString(@"disk_insertion_pop_tip_sub1",nil);
  93. // NSString *subTip2 = NSLocalizedString(@"disk_insertion_pop_tip_sub2",nil);
  94. // NSString *subTip3 = NSLocalizedString(@"disk_insertion_pop_tip_sub3",nil);
  95. //
  96. // NSArray *titleArr = @[subTip1,subTip2,subTip3];
  97. // CGFloat labelSpace = 10.0;
  98. // CGFloat labelWidth = (imageW -20)/3.0;
  99. //
  100. // for (int i=0; i<titleArr.count; i++) {
  101. //
  102. // UILabel *subTipLab = [[UILabel alloc] init];
  103. // subTipLab.text = titleArr[i];
  104. // subTipLab.numberOfLines = 0;
  105. // subTipLab.textAlignment = NSTextAlignmentCenter;
  106. // subTipLab.textColor = [UIColor hwColor:@"##0A132B" alpha:1.0];
  107. // subTipLab.font = [UIFont systemFontOfSize:14.0];
  108. // [topImage addSubview:subTipLab];
  109. //
  110. // [subTipLab mas_makeConstraints:^(MASConstraintMaker *make) {
  111. // make.height.mas_equalTo(40);
  112. // make.width.mas_equalTo(labelWidth);
  113. // make.left.mas_equalTo(i*(labelSpace + labelWidth));
  114. // make.bottom.mas_equalTo(0);
  115. // }];
  116. // }
  117. NSString *bottomTip1Str = NSLocalizedString(@"disk_insertion_pop_tip3",nil);
  118. UILabel *bottomTip1Lab = [[UILabel alloc] init];
  119. bottomTip1Lab.text = bottomTip1Str;
  120. bottomTip1Lab.textAlignment = NSTextAlignmentCenter;
  121. bottomTip1Lab.numberOfLines = 0;
  122. bottomTip1Lab.textColor = [UIColor hwColor:@"#151515" alpha:0.5];
  123. //bottomTip1Lab.font = [UIFont boldSystemFontOfSize:12.0];
  124. bottomTip1Lab.adjustsFontSizeToFitWidth = YES;
  125. [_whiteBgView addSubview:bottomTip1Lab];
  126. [bottomTip1Lab mas_makeConstraints:^(MASConstraintMaker *make) {
  127. make.height.mas_equalTo(15);
  128. make.right.mas_equalTo(-15.f);
  129. make.left.mas_equalTo(15.f);
  130. make.top.mas_equalTo(animation.mas_bottom).offset(0.0);
  131. }];
  132. NSString *bottomTipStr = NSLocalizedString(@"disk_insertion_pop_tip2",nil);
  133. UILabel *bottomTipLab = [[UILabel alloc] init];
  134. bottomTipLab.text = bottomTipStr;
  135. //bottomTipLab.textAlignment = NSTextAlignmentCenter;
  136. bottomTipLab.numberOfLines = 0;
  137. bottomTipLab.textColor = [UIColor hwColor:@"#DD4E4E" alpha:1.0];
  138. bottomTipLab.font = [UIFont boldSystemFontOfSize:12.0];
  139. [_whiteBgView addSubview:bottomTipLab];
  140. [bottomTipLab mas_makeConstraints:^(MASConstraintMaker *make) {
  141. make.height.mas_equalTo(50);
  142. make.right.mas_equalTo(-15.f);
  143. make.left.mas_equalTo(15.f);
  144. make.top.mas_equalTo(bottomTip1Lab.mas_bottom).offset(10.0);
  145. }];
  146. UIButton *konwBut = [[UIButton alloc] init];
  147. [konwBut setTitle:NSLocalizedString(@"guide_set_pwd_guide_know",nil) forState:UIControlStateNormal];
  148. konwBut.layer.cornerRadius = 8;
  149. konwBut.layer.masksToBounds = YES;
  150. [konwBut addTarget:self action:@selector(colseFun) forControlEvents:UIControlEventTouchUpInside];
  151. [_whiteBgView addSubview:konwBut];
  152. CAGradientLayer *gradientLayer = [CAGradientLayer layer];
  153. gradientLayer.startPoint = CGPointMake(0, 0.5);
  154. gradientLayer.endPoint = CGPointMake(0.97, 0.5);
  155. gradientLayer.frame = CGRectMake(0, 0, imageW, 48);
  156. gradientLayer.colors = @[(__bridge NSString *)[UIColor hwColor:@"#0CDEFD" alpha:1.0].CGColor, (__bridge NSString *)[UIColor hwColor:@"#058DFB" alpha:1.0].CGColor];
  157. gradientLayer.locations = @[@(0), @(1.0f)];
  158. [konwBut.layer addSublayer:gradientLayer];
  159. [konwBut mas_makeConstraints:^(MASConstraintMaker *make) {
  160. make.height.mas_equalTo(48);
  161. make.width.mas_equalTo(imageW);
  162. make.centerX.mas_equalTo(0.f);
  163. make.bottom.mas_equalTo(-(30 + safeArea));
  164. }];
  165. }
  166. - (void)colseFun
  167. {
  168. [self removeFromSuperview];
  169. }
  170. @end