GuideView.m 8.9 KB

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