GuideView.m 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  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.height.mas_equalTo(28);
  45. }];
  46. /*左头部标签*/
  47. UILabel *topLeftLabel = [[UILabel alloc] init];
  48. [topLeftLabel setFont:[UIFont boldSystemFontOfSize:30]];
  49. [topLeftLabel setTextAlignment:(NSTextAlignmentRight)];
  50. [topLeftLabel setTextColor:HW0A132BColor];
  51. [topLeftLabel setText:NSLocalizedString(@"guide_welcome",nil)];
  52. [bgImageView addSubview:topLeftLabel];
  53. [topLeftLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  54. make.top.mas_equalTo(H_STATE_BAR + 86.f);
  55. make.left.mas_equalTo(0.f);
  56. make.right.equalTo(bgImageView.mas_centerX).offset(-3);
  57. }];
  58. /*右头部标签*/
  59. UILabel *topRightLabel = [[UILabel alloc] init];
  60. [topRightLabel setFont:[UIFont boldSystemFontOfSize:30]];
  61. [topRightLabel setTextColor:HW0458E3Color];
  62. [topRightLabel setText:NSLocalizedString(@"guide_welcome",nil)];
  63. [bgImageView addSubview:topRightLabel];
  64. [topRightLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  65. make.top.mas_equalTo(H_STATE_BAR + 86.f);
  66. make.right.mas_equalTo(0.f);
  67. make.left.equalTo(bgImageView.mas_centerX).offset(3);
  68. }];
  69. /*详情标签*/
  70. UILabel *middleLabel = [[UILabel alloc] init];
  71. [middleLabel setTextColor:HW0A132BColor];
  72. [middleLabel setNumberOfLines:0];
  73. [middleLabel setTextAlignment:(NSTextAlignmentCenter)];
  74. [middleLabel setFont:[UIFont systemFontOfSize:20.f]];
  75. [middleLabel setText:tips];
  76. [bgImageView addSubview:middleLabel];
  77. [middleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  78. make.top.equalTo(topRightLabel.mas_bottom).offset(19.f);
  79. make.right.mas_equalTo(-20.f);
  80. make.left.mas_equalTo(20.f);
  81. }];
  82. /*中间图片*/
  83. UIImage *middleImage = [UIImage imageNamed:imageName];
  84. UIImageView *middleImageView = [[UIImageView alloc] initWithImage:middleImage];
  85. [bgImageView addSubview:middleImageView];
  86. [middleImageView mas_makeConstraints:^(MASConstraintMaker *make) {
  87. make.top.equalTo(middleLabel.mas_bottom).offset(8.f);
  88. make.left.mas_equalTo(0);
  89. make.right.mas_equalTo(0);
  90. make.height.mas_equalTo((middleImage.size.height/middleImage.size.width)*SCREEN_W);
  91. }];
  92. /*底部标签*/
  93. UILabel *bottomLabel = [[UILabel alloc] init];
  94. [bottomLabel setTextColor:HW9D9D9DColor];
  95. [bottomLabel setNumberOfLines:0];
  96. [bottomLabel setTextAlignment:(NSTextAlignmentCenter)];
  97. [bottomLabel setFont:[UIFont systemFontOfSize:14.f]];
  98. [bottomLabel setText:NSLocalizedString(@"guide_set_sys_value",nil)];
  99. [bgImageView addSubview:bottomLabel];
  100. [bottomLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  101. make.right.mas_equalTo(-20.f);
  102. make.left.mas_equalTo(20.f);
  103. make.bottom.mas_equalTo(-24.f);
  104. }];
  105. for (NSInteger nfori = 0; nfori < 4; nfori++) {
  106. UIView *pointView = [[UIView alloc] init];
  107. [pointView setBackgroundColor:[UIColor whiteColor]];
  108. [pointView.layer setCornerRadius:2.f];
  109. [bgImageView addSubview:pointView];
  110. [pointView mas_makeConstraints:^(MASConstraintMaker *make) {
  111. make.width.mas_equalTo(4.f);
  112. make.height.mas_equalTo(4.f);
  113. make.bottom.mas_equalTo(-51.f);
  114. make.left.equalTo(bgImageView.mas_centerX).offset((nfori - 2)*(8+4) + 4.f);
  115. }];
  116. }
  117. pointSelectView = [[UIView alloc] init];
  118. [pointSelectView setBackgroundColor:HW058DFBColor];
  119. [pointSelectView.layer setCornerRadius:2.f];
  120. [bgImageView addSubview:pointSelectView];
  121. [pointSelectView mas_makeConstraints:^(MASConstraintMaker *make) {
  122. make.width.mas_equalTo(4.f);
  123. make.height.mas_equalTo(4.f);
  124. make.bottom.mas_equalTo(-51.f);
  125. make.left.equalTo(bgImageView.mas_centerX).offset((index - 2)*(8+4) + 4.f);
  126. }];
  127. /*底部进度条*/
  128. // HW01B7EAColor
  129. CAGradientLayer *gl = [CAGradientLayer layer];
  130. gl.frame = CGRectMake(0,0,(index + 1)*SCREEN_W/4.f,8);
  131. gl.startPoint = CGPointMake(0, 0.5);
  132. gl.endPoint = CGPointMake(1, 0.5);
  133. gl.colors = @[(__bridge id)HW02DCF6Color.CGColor, (__bridge id)HW01B7EAColor.CGColor];
  134. gl.locations = @[@(0), @(1.0f)];
  135. UIView *prossView = [[UIView alloc] initWithFrame:(CGRectMake(0, 0, 25.f, 2.f))];
  136. [prossView setBackgroundColor:[UIColor clearColor]];
  137. [prossView.layer addSublayer:gl];
  138. [bgImageView addSubview:prossView];
  139. [prossView mas_makeConstraints:^(MASConstraintMaker *make) {
  140. make.width.mas_equalTo((index + 1)*SCREEN_W/4.f);
  141. make.height.mas_equalTo(8.f);
  142. make.bottom.mas_equalTo(0.f);
  143. make.left.mas_equalTo(0.f);
  144. }];
  145. }
  146. @end