newerGuideView.m 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222
  1. //
  2. // newerGuideView.m
  3. // 双子星云手机
  4. //
  5. // Created by xd h on 2024/7/20.
  6. //
  7. #import "newerGuideView.h"
  8. @interface newerGuideView ()<UITextViewDelegate>
  9. @property(nonatomic,strong) UILabel*titleLabel;
  10. @end
  11. @implementation newerGuideView
  12. - (id)initWithFrame:(CGRect)frame{
  13. self = [super initWithFrame:frame];
  14. self.backgroundColor = [UIColor hwColor:@"#000000" alpha:0.6];
  15. [self drawAnyView];
  16. return self;
  17. }
  18. -(void)drawAnyView
  19. {
  20. UIView *whiteBgView = [[UIView alloc] init];
  21. whiteBgView.backgroundColor = [UIColor whiteColor];
  22. [self addSubview:whiteBgView];
  23. whiteBgView.layer.cornerRadius = 8;
  24. whiteBgView.layer.masksToBounds = YES;
  25. [whiteBgView mas_makeConstraints:^(MASConstraintMaker *make) {
  26. make.centerX.mas_equalTo(0);
  27. make.width.mas_equalTo(300);
  28. make.height.mas_equalTo(288);
  29. make.centerY.mas_equalTo(0);
  30. }];
  31. UIImageView * imageBgView = [[UIImageView alloc] init];
  32. imageBgView.image = [UIImage imageNamed:@"nas_newerGuide"];
  33. [self addSubview:imageBgView];
  34. [imageBgView mas_makeConstraints:^(MASConstraintMaker *make) {
  35. make.centerX.mas_equalTo(0);
  36. make.width.mas_equalTo(300);
  37. make.height.mas_equalTo(162);
  38. make.top.equalTo(whiteBgView.mas_top).offset(-66);
  39. }];
  40. //新手视频
  41. UILabel *titleLabel = [[UILabel alloc] init];
  42. titleLabel.font = [UIFont boldSystemFontOfSize:18.0];
  43. titleLabel.textColor = [UIColor hwColor:@"#151515"];
  44. titleLabel.text = NSLocalizedString(@"NAS_newer_guide_video",nil);
  45. titleLabel.textAlignment = NSTextAlignmentCenter;
  46. [whiteBgView addSubview:titleLabel];
  47. [titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  48. make.height.mas_equalTo(20);
  49. make.left.mas_equalTo(0);
  50. make.right.mas_equalTo(0);
  51. make.centerY.mas_equalTo(-15);
  52. }];
  53. //为您打开新世界的大门
  54. UILabel *title2Label = [[UILabel alloc] init];
  55. title2Label.font = [UIFont systemFontOfSize:14.0];
  56. title2Label.textColor = [UIColor hwColor:@"#0A132B"];
  57. title2Label.text = NSLocalizedString(@"NAS_newer_guide_video_to_world",nil);
  58. title2Label.textAlignment = NSTextAlignmentCenter;
  59. [whiteBgView addSubview:title2Label];
  60. [title2Label mas_makeConstraints:^(MASConstraintMaker *make) {
  61. make.height.mas_equalTo(20);
  62. make.left.mas_equalTo(0);
  63. make.right.mas_equalTo(0);
  64. make.top.equalTo(titleLabel.mas_bottom).offset(8);
  65. }];
  66. //您可以在【我的>新手引导】查看操作教程
  67. // UILabel *title3Label = [[UILabel alloc] init];
  68. // title3Label.font = [UIFont systemFontOfSize:14.0];
  69. // title3Label.textColor = [UIColor hwColor:@"#0A132B"];
  70. // //title3Label.text = NSLocalizedString(@"NAS_newer_guide_video_to_world",nil);
  71. // title3Label.textAlignment = NSTextAlignmentCenter;
  72. // [whiteBgView addSubview:title3Label];
  73. //
  74. // [title3Label mas_makeConstraints:^(MASConstraintMaker *make) {
  75. // make.height.mas_equalTo(20);
  76. // make.left.mas_equalTo(0);
  77. // make.right.mas_equalTo(0);
  78. // make.top.equalTo(title2Label.mas_bottom).offset(8);
  79. // }];
  80. UITextView *contentTV = [[UITextView alloc] init];
  81. contentTV.textColor = [UIColor hwColor:@"#0A132B"];
  82. // contentTV.font = [UIFont systemFontOfSize:16.0];
  83. // contentTV.textAlignment = NSTextAlignmentCenter;
  84. contentTV.delegate = self;
  85. contentTV.editable = NO; //必须禁止输入,否则点击将弹出输入键盘
  86. contentTV.scrollEnabled = NO;
  87. [whiteBgView addSubview:contentTV];
  88. [contentTV mas_makeConstraints:^(MASConstraintMaker *make) {
  89. make.height.mas_equalTo(20);
  90. make.left.mas_equalTo(0);
  91. make.right.mas_equalTo(0);
  92. make.top.equalTo(title2Label.mas_bottom).offset(8);
  93. }];
  94. NSString *title1 = NSLocalizedString(@"NAS_newer_guide_video_tip1",nil);
  95. NSString *title2 = NSLocalizedString(@"NAS_newer_guide_video_tip2",nil);
  96. NSString *title3 = NSLocalizedString(@"NAS_newer_guide_video_tip3",nil);
  97. NSString *fullTitle = [[NSString alloc] initWithFormat:@"%@ %@%@",title1,title2,title3];
  98. NSMutableAttributedString *attrStr = [[NSMutableAttributedString alloc] initWithString:fullTitle];
  99. NSRange redRange = NSMakeRange([fullTitle rangeOfString:title2].location, [fullTitle rangeOfString:title2].length);
  100. UIColor *noteColor =[UIColor hwColor:@"#01B7EA" alpha:1.0];
  101. [attrStr addAttribute:NSForegroundColorAttributeName value:noteColor range:redRange];
  102. [attrStr addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:14.0] range:NSMakeRange(0, attrStr.length)];
  103. // 设置段落样式以实现水平中间对齐
  104. NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle alloc] init];
  105. paragraphStyle.alignment = NSTextAlignmentCenter; // 水平中间对齐
  106. [attrStr addAttribute:NSParagraphStyleAttributeName value:paragraphStyle range:NSMakeRange(0, attrStr.length)];
  107. //title3Label.attributedText = attrStr;
  108. [attrStr addAttribute:NSLinkAttributeName
  109. value:@"didclick1://"
  110. range:redRange];
  111. contentTV.attributedText = attrStr;
  112. UIButton *leftbut = [[UIButton alloc] init];
  113. leftbut.tag = 1;
  114. [leftbut addTarget:self action:@selector(didClickButtonFun:) forControlEvents:UIControlEventTouchUpInside];
  115. [leftbut setTitle:NSLocalizedString(@"NAS_newer_guide_not_newer",nil) forState:UIControlStateNormal];
  116. [leftbut setTitleColor:[UIColor hwColor:@"#0A132B"] forState:UIControlStateNormal];
  117. leftbut.titleLabel.font = [UIFont systemFontOfSize:16];
  118. leftbut.backgroundColor = [UIColor hwColor:@"#E3E8F1"];
  119. leftbut.layer.cornerRadius = 8;
  120. [whiteBgView addSubview:leftbut];
  121. [leftbut mas_makeConstraints:^(MASConstraintMaker *make) {
  122. make.left.mas_equalTo(30);
  123. make.width.mas_equalTo(110);
  124. make.height.mas_equalTo(40);
  125. make.bottom.mas_equalTo(-25);
  126. }];
  127. // gradient
  128. CAGradientLayer *gl = [CAGradientLayer layer];
  129. gl.frame = CGRectMake(0,0,110,40);
  130. gl.startPoint = CGPointMake(0.0, 0.5);
  131. gl.endPoint = CGPointMake(1, 0.5);
  132. gl.colors = @[(__bridge id)[UIColor hwColor:@"#0BDDFD"].CGColor, (__bridge id)[UIColor hwColor:@"#048CFB"].CGColor];
  133. gl.locations = @[@(0), @(1.0f)];
  134. UIButton *rightbut = [[UIButton alloc] init];
  135. [rightbut.layer addSublayer:gl];
  136. rightbut.tag = 2;
  137. [rightbut addTarget:self action:@selector(didClickButtonFun:) forControlEvents:UIControlEventTouchUpInside];
  138. [rightbut setTitle:NSLocalizedString(@"NAS_newer_guide_go_see",nil) forState:UIControlStateNormal];
  139. [rightbut setTitleColor:[UIColor hwColor:@"#FFFFFF"] forState:UIControlStateNormal];
  140. rightbut.titleLabel.font = [UIFont systemFontOfSize:16];
  141. rightbut.layer.cornerRadius = 8;
  142. rightbut.layer.masksToBounds = YES;
  143. [whiteBgView addSubview:rightbut];
  144. [rightbut mas_makeConstraints:^(MASConstraintMaker *make) {
  145. make.right.mas_equalTo(-30);
  146. make.width.mas_equalTo(110);
  147. make.height.mas_equalTo(40);
  148. make.bottom.mas_equalTo(-25);
  149. }];
  150. }
  151. #pragma mark ---- textView Delegate ----
  152. - (BOOL)textView:(UITextView *)textView shouldInteractWithURL:(NSURL *)URL inRange:(NSRange)characterRange interaction:(UITextItemInteraction)interaction
  153. {
  154. if([[URL scheme] isEqualToString:@"didclick1"]){
  155. [self removeFromSuperview];
  156. if(_didClickButtonFun){
  157. _didClickButtonFun(10);
  158. }
  159. return NO;
  160. }
  161. return YES;
  162. }
  163. #pragma mark 按钮事件
  164. - (void)didClickButtonFun:(UIButton*)but
  165. {
  166. NSInteger tag = but.tag;
  167. HLog(@"%ld",tag);
  168. [self removeFromSuperview];
  169. if(_didClickButtonFun){
  170. _didClickButtonFun(tag);
  171. }
  172. }
  173. @end