GuideView.m 8.3 KB

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