GuideView.m 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222
  1. //
  2. // GuideView.m
  3. // 创维盒子
  4. //
  5. // Created by APPLE on 2023/9/18.
  6. //
  7. #import "GuideView.h"
  8. #import <Masonry.h>
  9. #import "DDYLanguageTool.h"
  10. @interface GuideView(){
  11. UIView *pointSelectView;
  12. }
  13. @end
  14. @implementation GuideView
  15. /*
  16. // Only override drawRect: if you perform custom drawing.
  17. // An empty implementation adversely affects performance during animation.
  18. - (void)drawRect:(CGRect)rect {
  19. // Drawing code
  20. }
  21. */
  22. - (id)initWithTips:(NSString *)tips imageName:(NSString *)imageName index:(NSInteger)index{
  23. self = [super init];
  24. [self drawAnyViewWithTips:tips imageName:imageName index:index];
  25. return self;
  26. }
  27. - (void)drawAnyViewWithTips:(NSString *)tips imageName:(NSString *)imageName index:(NSInteger)index{
  28. [self setBackgroundColor:HWECECECColor];
  29. /*背景视图*/
  30. UIImageView *bgImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"guide_bg_icon"]];
  31. [self addSubview:bgImageView];
  32. [bgImageView mas_makeConstraints:^(MASConstraintMaker *make) {
  33. make.top.mas_equalTo(0);
  34. make.bottom.mas_equalTo(0);
  35. make.left.mas_equalTo(0);
  36. make.right.mas_equalTo(0);
  37. }];
  38. // guide_up_icon
  39. UIImageView *upImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"guide_up_icon"]];
  40. [bgImageView addSubview:upImageView];
  41. [upImageView mas_makeConstraints:^(MASConstraintMaker *make) {
  42. make.top.mas_equalTo(H_STATE_BAR + 12.f);
  43. make.left.mas_equalTo(25.f);
  44. make.width.mas_equalTo(132);
  45. make.height.mas_equalTo(28);
  46. }];
  47. /*跳过*/
  48. bgImageView.userInteractionEnabled = YES;
  49. UIButton *skipBtn = [[UIButton alloc] init];
  50. [skipBtn addTarget:self action:@selector(didClickButFun:) forControlEvents:(UIControlEventTouchUpInside)];
  51. [skipBtn setTitle:NSLocalizedString(@"guide_skip",nil) forState:(UIControlStateNormal)];
  52. //[skipBtn setTitleColor:HW999999Color forState:(UIControlStateNormal)];
  53. [skipBtn.titleLabel setFont:[UIFont systemFontOfSize:14.f]];
  54. [skipBtn.layer setCornerRadius:14.f];
  55. skipBtn.layer.borderColor = [UIColor whiteColor].CGColor;
  56. skipBtn.layer.borderWidth = 1.0;
  57. //[skipBtn setBackgroundColor:HWE3E8F1Color];
  58. skipBtn.clipsToBounds = YES;
  59. [self addSubview:skipBtn];
  60. [skipBtn mas_makeConstraints:^(MASConstraintMaker *make) {
  61. make.right.mas_equalTo(-20);
  62. make.width.mas_equalTo(80.f);
  63. make.top.equalTo(upImageView.mas_top).offset(0.f);
  64. make.height.mas_equalTo(28.f);
  65. }];
  66. NSString* curLanguage = [DDYLanguageTool ddy_AppLanguage];
  67. if(!curLanguage || curLanguage.length == 0){
  68. curLanguage = [DDYLanguageTool ddy_SystemLanguage];
  69. }
  70. CGFloat curFontSize = 30.0;
  71. // "zh-Hant-HK", "zh-Hans-US",
  72. if([curLanguage rangeOfString:@"ja"].location != NSNotFound){//中文和繁体
  73. curFontSize = 20.0;
  74. }
  75. NSString *strLeft = NSLocalizedString(@"guide_welcome",nil);
  76. NSString *strRight = NSLocalizedString(@"guide_start_sys_app_name",nil);
  77. NSString *totalStr = [[NSString alloc] initWithFormat:@"%@ %@",strLeft,strRight];
  78. NSMutableAttributedString *noteStr = [[NSMutableAttributedString alloc] initWithString:totalStr];
  79. NSRange redRange = NSMakeRange([totalStr rangeOfString:strRight].location, [totalStr rangeOfString:strRight].length);
  80. [noteStr addAttribute:NSForegroundColorAttributeName value:HW0458E3Color range:redRange];
  81. /*左头部标签*/
  82. UILabel *topLeftLabel = [[UILabel alloc] init];
  83. [topLeftLabel setFont:[UIFont boldSystemFontOfSize:curFontSize]];
  84. [topLeftLabel setTextAlignment:(NSTextAlignmentLeft)];
  85. [topLeftLabel setTextColor:HW0A132BColor];
  86. //[topLeftLabel setText:NSLocalizedString(@"guide_welcome",nil)];
  87. topLeftLabel.attributedText = noteStr;
  88. [bgImageView addSubview:topLeftLabel];
  89. [topLeftLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  90. make.top.mas_equalTo(H_STATE_BAR + 86.f);
  91. // make.left.mas_equalTo(0.f);
  92. // make.right.equalTo(bgImageView.mas_centerX).offset(-3);
  93. make.left.mas_equalTo(20.f);
  94. make.right.mas_equalTo(-20.f);
  95. make.height.mas_equalTo(40.f);
  96. }];
  97. /*右头部标签*/
  98. // UILabel *topRightLabel = [[UILabel alloc] init];
  99. // [topRightLabel setFont:[UIFont boldSystemFontOfSize:curFontSize]];
  100. // [topRightLabel setTextColor:HW0458E3Color];
  101. // [topRightLabel setText:NSLocalizedString(@"guide_start_sys_app_name",nil)];
  102. // [bgImageView addSubview:topRightLabel];
  103. // [topRightLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  104. // make.top.mas_equalTo(H_STATE_BAR + 86.f);
  105. // make.right.mas_equalTo(0.f);
  106. // make.left.equalTo(bgImageView.mas_centerX).offset(3);
  107. // }];
  108. /*详情标签*/
  109. UILabel *middleLabel = [[UILabel alloc] init];
  110. [middleLabel setTextColor:HW0A132BColor];
  111. [middleLabel setNumberOfLines:0];
  112. [middleLabel setTextAlignment:(NSTextAlignmentCenter)];
  113. [middleLabel setFont:[UIFont systemFontOfSize:20.f]];
  114. [middleLabel setText:tips];
  115. [bgImageView addSubview:middleLabel];
  116. [middleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  117. make.top.equalTo(topLeftLabel.mas_bottom).offset(19.f);
  118. make.right.mas_equalTo(-20.f);
  119. make.left.mas_equalTo(20.f);
  120. }];
  121. /*中间图片*/
  122. UIImage *middleImage = [UIImage imageNamed:imageName];
  123. UIImageView *middleImageView = [[UIImageView alloc] initWithImage:middleImage];
  124. [bgImageView addSubview:middleImageView];
  125. [middleImageView mas_makeConstraints:^(MASConstraintMaker *make) {
  126. make.top.equalTo(middleLabel.mas_bottom).offset(8.f);
  127. make.left.mas_equalTo(0);
  128. make.right.mas_equalTo(0);
  129. make.height.mas_equalTo((middleImage.size.height/middleImage.size.width)*SCREEN_W);
  130. }];
  131. /*底部标签*/
  132. UILabel *bottomLabel = [[UILabel alloc] init];
  133. [bottomLabel setTextColor:HW9D9D9DColor];
  134. [bottomLabel setNumberOfLines:0];
  135. [bottomLabel setTextAlignment:(NSTextAlignmentCenter)];
  136. [bottomLabel setFont:[UIFont systemFontOfSize:14.f]];
  137. [bottomLabel setText:NSLocalizedString(@"guide_set_sys_value",nil)];
  138. [bgImageView addSubview:bottomLabel];
  139. [bottomLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  140. make.right.mas_equalTo(-20.f);
  141. make.left.mas_equalTo(20.f);
  142. make.bottom.mas_equalTo(-24.f);
  143. }];
  144. for (NSInteger nfori = 0; nfori < 4; nfori++) {
  145. UIView *pointView = [[UIView alloc] init];
  146. [pointView setBackgroundColor:[UIColor whiteColor]];
  147. [pointView.layer setCornerRadius:2.f];
  148. [bgImageView addSubview:pointView];
  149. [pointView mas_makeConstraints:^(MASConstraintMaker *make) {
  150. make.width.mas_equalTo(4.f);
  151. make.height.mas_equalTo(4.f);
  152. make.bottom.mas_equalTo(-51.f);
  153. make.left.equalTo(bgImageView.mas_centerX).offset((nfori - 2)*(8+4) + 4.f);
  154. }];
  155. }
  156. pointSelectView = [[UIView alloc] init];
  157. [pointSelectView setBackgroundColor:HW058DFBColor];
  158. [pointSelectView.layer setCornerRadius:2.f];
  159. [bgImageView addSubview:pointSelectView];
  160. [pointSelectView mas_makeConstraints:^(MASConstraintMaker *make) {
  161. make.width.mas_equalTo(4.f);
  162. make.height.mas_equalTo(4.f);
  163. make.bottom.mas_equalTo(-51.f);
  164. make.left.equalTo(bgImageView.mas_centerX).offset((index - 2)*(8+4) + 4.f);
  165. }];
  166. /*底部进度条*/
  167. // HW01B7EAColor
  168. CAGradientLayer *gl = [CAGradientLayer layer];
  169. gl.frame = CGRectMake(0,0,(index + 1)*SCREEN_W/4.f,8);
  170. gl.startPoint = CGPointMake(0, 0.5);
  171. gl.endPoint = CGPointMake(1, 0.5);
  172. gl.colors = @[(__bridge id)HW02DCF6Color.CGColor, (__bridge id)HW01B7EAColor.CGColor];
  173. gl.locations = @[@(0), @(1.0f)];
  174. UIView *prossView = [[UIView alloc] initWithFrame:(CGRectMake(0, 0, 25.f, 2.f))];
  175. [prossView setBackgroundColor:[UIColor clearColor]];
  176. [prossView.layer addSublayer:gl];
  177. [bgImageView addSubview:prossView];
  178. [prossView mas_makeConstraints:^(MASConstraintMaker *make) {
  179. make.width.mas_equalTo((index + 1)*SCREEN_W/4.f);
  180. make.height.mas_equalTo(8.f);
  181. make.bottom.mas_equalTo(0.f);
  182. make.left.mas_equalTo(0.f);
  183. }];
  184. }
  185. #pragma mark 点击按钮
  186. -(void)didClickButFun:(UIButton*)but
  187. {
  188. if(_didClickButton){
  189. _didClickButton();
  190. }
  191. }
  192. @end