GuideView.m 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198
  1. //
  2. // GuideView.m
  3. // 创维盒子
  4. //
  5. // Created by APPLE on 2023/9/18.
  6. //
  7. #import "GuideView.h"
  8. #import <Masonry.h>
  9. @interface GuideView(){
  10. UIView *pointSelectView;
  11. }
  12. @end
  13. @implementation GuideView
  14. /*
  15. // Only override drawRect: if you perform custom drawing.
  16. // An empty implementation adversely affects performance during animation.
  17. - (void)drawRect:(CGRect)rect {
  18. // Drawing code
  19. }
  20. */
  21. - (id)initWithTips:(NSString *)tips imageName:(NSString *)imageName index:(NSInteger)index{
  22. self = [super init];
  23. [self drawAnyViewWithTips:tips imageName:imageName index:index];
  24. return self;
  25. }
  26. - (void)drawAnyViewWithTips:(NSString *)tips imageName:(NSString *)imageName index:(NSInteger)index{
  27. [self setBackgroundColor:HWECECECColor];
  28. /*背景视图*/
  29. UIImageView *bgImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"guide_bg_icon"]];
  30. [self addSubview:bgImageView];
  31. [bgImageView mas_makeConstraints:^(MASConstraintMaker *make) {
  32. make.top.mas_equalTo(0);
  33. make.bottom.mas_equalTo(0);
  34. make.left.mas_equalTo(0);
  35. make.right.mas_equalTo(0);
  36. }];
  37. // guide_up_icon
  38. UIImageView *upImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"guide_up_icon"]];
  39. [bgImageView addSubview:upImageView];
  40. [upImageView mas_makeConstraints:^(MASConstraintMaker *make) {
  41. make.top.mas_equalTo(H_STATE_BAR + 12.f);
  42. make.left.mas_equalTo(25.f);
  43. //make.width.mas_equalTo(132);
  44. make.width.mas_equalTo(100);
  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. /*左头部标签*/
  67. UILabel *topLeftLabel = [[UILabel alloc] init];
  68. [topLeftLabel setFont:[UIFont boldSystemFontOfSize:30]];
  69. [topLeftLabel setTextAlignment:(NSTextAlignmentRight)];
  70. [topLeftLabel setTextColor:HW0A132BColor];
  71. [topLeftLabel setText:NSLocalizedString(@"guide_welcome",nil)];
  72. [bgImageView addSubview:topLeftLabel];
  73. [topLeftLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  74. make.top.mas_equalTo(H_STATE_BAR + 86.f);
  75. make.left.mas_equalTo(0.f);
  76. make.right.equalTo(bgImageView.mas_centerX).offset(-3);
  77. }];
  78. /*右头部标签*/
  79. UILabel *topRightLabel = [[UILabel alloc] init];
  80. [topRightLabel setFont:[UIFont boldSystemFontOfSize:30]];
  81. [topRightLabel setTextColor:HW0458E3Color];
  82. [topRightLabel setText:NSLocalizedString(@"guide_start_sys_app_name",nil)];
  83. [bgImageView addSubview:topRightLabel];
  84. [topRightLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  85. make.top.mas_equalTo(H_STATE_BAR + 86.f);
  86. make.right.mas_equalTo(0.f);
  87. make.left.equalTo(bgImageView.mas_centerX).offset(3);
  88. }];
  89. /*详情标签*/
  90. UILabel *middleLabel = [[UILabel alloc] init];
  91. [middleLabel setTextColor:HW0A132BColor];
  92. [middleLabel setNumberOfLines:0];
  93. [middleLabel setTextAlignment:(NSTextAlignmentCenter)];
  94. [middleLabel setFont:[UIFont systemFontOfSize:20.f]];
  95. [middleLabel setText:tips];
  96. [bgImageView addSubview:middleLabel];
  97. [middleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  98. make.top.equalTo(topRightLabel.mas_bottom).offset(19.f);
  99. make.right.mas_equalTo(-20.f);
  100. make.left.mas_equalTo(20.f);
  101. }];
  102. /*中间图片*/
  103. UIImage *middleImage = [UIImage imageNamed:imageName];
  104. UIImageView *middleImageView = [[UIImageView alloc] initWithImage:middleImage];
  105. [bgImageView addSubview:middleImageView];
  106. [middleImageView mas_makeConstraints:^(MASConstraintMaker *make) {
  107. make.top.equalTo(middleLabel.mas_bottom).offset(8.f);
  108. make.left.mas_equalTo(0);
  109. make.right.mas_equalTo(0);
  110. make.height.mas_equalTo((middleImage.size.height/middleImage.size.width)*SCREEN_W);
  111. }];
  112. /*底部标签*/
  113. UILabel *bottomLabel = [[UILabel alloc] init];
  114. [bottomLabel setTextColor:HW9D9D9DColor];
  115. [bottomLabel setNumberOfLines:0];
  116. [bottomLabel setTextAlignment:(NSTextAlignmentCenter)];
  117. [bottomLabel setFont:[UIFont systemFontOfSize:14.f]];
  118. [bottomLabel setText:NSLocalizedString(@"guide_set_sys_value",nil)];
  119. [bgImageView addSubview:bottomLabel];
  120. [bottomLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  121. make.right.mas_equalTo(-20.f);
  122. make.left.mas_equalTo(20.f);
  123. make.bottom.mas_equalTo(-24.f);
  124. }];
  125. for (NSInteger nfori = 0; nfori < 4; nfori++) {
  126. UIView *pointView = [[UIView alloc] init];
  127. [pointView setBackgroundColor:[UIColor whiteColor]];
  128. [pointView.layer setCornerRadius:2.f];
  129. [bgImageView addSubview:pointView];
  130. [pointView mas_makeConstraints:^(MASConstraintMaker *make) {
  131. make.width.mas_equalTo(4.f);
  132. make.height.mas_equalTo(4.f);
  133. make.bottom.mas_equalTo(-51.f);
  134. make.left.equalTo(bgImageView.mas_centerX).offset((nfori - 2)*(8+4) + 4.f);
  135. }];
  136. }
  137. pointSelectView = [[UIView alloc] init];
  138. [pointSelectView setBackgroundColor:HW058DFBColor];
  139. [pointSelectView.layer setCornerRadius:2.f];
  140. [bgImageView addSubview:pointSelectView];
  141. [pointSelectView mas_makeConstraints:^(MASConstraintMaker *make) {
  142. make.width.mas_equalTo(4.f);
  143. make.height.mas_equalTo(4.f);
  144. make.bottom.mas_equalTo(-51.f);
  145. make.left.equalTo(bgImageView.mas_centerX).offset((index - 2)*(8+4) + 4.f);
  146. }];
  147. /*底部进度条*/
  148. // HW01B7EAColor
  149. CAGradientLayer *gl = [CAGradientLayer layer];
  150. gl.frame = CGRectMake(0,0,(index + 1)*SCREEN_W/4.f,8);
  151. gl.startPoint = CGPointMake(0, 0.5);
  152. gl.endPoint = CGPointMake(1, 0.5);
  153. gl.colors = @[(__bridge id)HW02DCF6Color.CGColor, (__bridge id)HW01B7EAColor.CGColor];
  154. gl.locations = @[@(0), @(1.0f)];
  155. UIView *prossView = [[UIView alloc] initWithFrame:(CGRectMake(0, 0, 25.f, 2.f))];
  156. [prossView setBackgroundColor:[UIColor clearColor]];
  157. [prossView.layer addSublayer:gl];
  158. [bgImageView addSubview:prossView];
  159. [prossView mas_makeConstraints:^(MASConstraintMaker *make) {
  160. make.width.mas_equalTo((index + 1)*SCREEN_W/4.f);
  161. make.height.mas_equalTo(8.f);
  162. make.bottom.mas_equalTo(0.f);
  163. make.left.mas_equalTo(0.f);
  164. }];
  165. }
  166. #pragma mark 点击按钮
  167. -(void)didClickButFun:(UIButton*)but
  168. {
  169. if(_didClickButton){
  170. _didClickButton();
  171. }
  172. }
  173. @end