ASPointHeadView.m 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208
  1. //
  2. // ASPointHeadView.m
  3. // Asteria
  4. //
  5. // Created by iOS on 2023/6/19.
  6. //
  7. #import "ASPointHeadView.h"
  8. @interface ASPointHeadView ()
  9. @property (nonatomic, strong) UIView *topBgV;
  10. @property (nonatomic, strong) UIView *bottomBgV;
  11. @property (nonatomic, strong) UILabel *numLb;
  12. @property (nonatomic, strong) UILabel *numDesLb;
  13. @property (nonatomic, strong) UIButton *detailBt;
  14. @property (nonatomic, strong) UIButton *ruleBt;
  15. @property (nonatomic, strong) UILabel *bottomTitleLb;
  16. @end
  17. @implementation ASPointHeadView
  18. - (void)setData:(NSString *)num {
  19. self.numLb.text = num;
  20. }
  21. - (void)ruleAction {
  22. if (self.ruleCallBack) {
  23. self.ruleCallBack();
  24. }
  25. }
  26. - (void)detailAction {
  27. if (self.detailCallBack) {
  28. self.detailCallBack();
  29. }
  30. }
  31. - (instancetype)initWithFrame:(CGRect)frame {
  32. CGRect rect = CGRectMake(0, 0, KScreenWidth, 205);
  33. self = [super initWithFrame:rect];
  34. if (self) {
  35. [self loadsubV];
  36. }
  37. return self;
  38. }
  39. - (void)loadsubV {
  40. self.backgroundColor = _E0FFF5;
  41. [self addSubview:self.topBgV];
  42. [self addSubview:self.bottomBgV];
  43. [self.topBgV addSubview:self.numLb];
  44. [self.topBgV addSubview:self.numDesLb];
  45. [self.topBgV addSubview:self.detailBt];
  46. [self.topBgV addSubview:self.ruleBt];
  47. [self.bottomBgV addSubview:self.bottomTitleLb];
  48. [self.bottomBgV mas_makeConstraints:^(MASConstraintMaker *make) {
  49. make.height.equalTo(@70);
  50. make.bottom.leading.trailing.equalTo(self);
  51. }];
  52. [self.topBgV mas_makeConstraints:^(MASConstraintMaker *make) {
  53. make.top.leading.trailing.equalTo(self);
  54. make.height.equalTo(@135);
  55. }];
  56. [self.numLb mas_makeConstraints:^(MASConstraintMaker *make) {
  57. make.leading.equalTo(self.topBgV).offset(30);
  58. make.height.equalTo(@58);
  59. make.top.equalTo(self.topBgV).offset(30);
  60. }];
  61. [self.numDesLb mas_makeConstraints:^(MASConstraintMaker *make) {
  62. make.leading.equalTo(self.numLb);
  63. make.top.equalTo(self.numLb.mas_bottom);
  64. make.height.equalTo(@17);
  65. }];
  66. [self.ruleBt mas_makeConstraints:^(MASConstraintMaker *make) {
  67. make.width.equalTo(@44);
  68. make.top.equalTo(self.topBgV).offset(30);
  69. make.trailing.equalTo(self.topBgV).offset(-15);
  70. make.height.equalTo(@17);
  71. }];
  72. [self.detailBt mas_makeConstraints:^(MASConstraintMaker *make) {
  73. make.height.equalTo(self.ruleBt);
  74. make.width.equalTo(@53);
  75. make.trailing.equalTo(self.ruleBt.mas_leading).offset(0);
  76. make.centerY.equalTo(self.ruleBt);
  77. }];
  78. [self.bottomTitleLb mas_makeConstraints:^(MASConstraintMaker *make) {
  79. make.top.equalTo(self.bottomBgV).offset(30);
  80. make.leading.equalTo(self.bottomBgV).offset(20);
  81. make.trailing.equalTo(self.bottomBgV).offset(-20);
  82. make.height.equalTo(@30);
  83. }];
  84. }
  85. - (UIView *)topBgV {
  86. if (!_topBgV) {
  87. UIView *v = [UIView baseV];
  88. v.backgroundColor = _E0FFF5;
  89. _topBgV = v;
  90. }
  91. return _topBgV;
  92. }
  93. - (UIView *)bottomBgV {
  94. if (!_bottomBgV) {
  95. UIView *v = [UIView baseV];
  96. v.frame = CGRectMake(0, 0, KScreenWidth, 70);
  97. v.backgroundColor = Col_FFF;
  98. // 左上和右上为圆角
  99. UIBezierPath *cornerRadiusPath = [UIBezierPath bezierPathWithRoundedRect:v.bounds byRoundingCorners:UIRectCornerTopRight | UIRectCornerTopLeft cornerRadii:CGSizeMake(16, 16)];
  100. CAShapeLayer *cornerRadiusLayer = [ [CAShapeLayer alloc ] init];
  101. cornerRadiusLayer.frame = v.bounds;
  102. cornerRadiusLayer.path = cornerRadiusPath.CGPath;
  103. v.layer.mask = cornerRadiusLayer;
  104. _bottomBgV = v;
  105. }
  106. return _bottomBgV;
  107. }
  108. - (UILabel *)bottomTitleLb {
  109. if (!_bottomTitleLb) {
  110. UILabel *lb = [UILabel baseLb];
  111. lb.font = [UIFont fontWithName:Rob_Bold size:24];
  112. lb.textColor = Col_000;
  113. lb.textAlignment = NSTextAlignmentLeft;
  114. lb.text = @"ERAN POINTS";
  115. _bottomTitleLb = lb;
  116. }
  117. return _bottomTitleLb;
  118. }
  119. - (UILabel *)numLb {
  120. if (!_numLb) {
  121. UILabel *lb = [UILabel baseLb];
  122. lb.font = [UIFont fontWithName:Rob_Bold size:48];
  123. lb.textColor = Col_000;
  124. lb.textAlignment = NSTextAlignmentLeft;
  125. _numLb = lb;
  126. }
  127. return _numLb;
  128. }
  129. - (UILabel *)numDesLb {
  130. if (!_numDesLb) {
  131. UILabel *lb = [UILabel baseLb];
  132. lb.font = [UIFont fontWithName:Rob_Regular size:14];
  133. lb.textColor = Col_000;
  134. lb.textAlignment = NSTextAlignmentLeft;
  135. lb.text = @"My Points";
  136. _numDesLb = lb;
  137. }
  138. return _numDesLb;
  139. }
  140. - (UIButton *)detailBt {
  141. if (!_detailBt) {
  142. UIButton *bt = [UIButton buttonWithType:UIButtonTypeCustom];
  143. NSMutableAttributedString *str = [[NSMutableAttributedString alloc] initWithString:@"Details"];
  144. [str addAttributes:@{
  145. NSForegroundColorAttributeName:_0B0B0B,
  146. NSUnderlineStyleAttributeName: @(NSUnderlineStyleSingle),
  147. NSFontAttributeName:[UIFont fontWithName:Rob_Regular size:14]
  148. } range:NSMakeRange(0, str.length)];
  149. [bt setAttributedTitle:str forState:UIControlStateNormal];
  150. [bt addTarget:self action:@selector(detailAction) forControlEvents:UIControlEventTouchUpInside];
  151. _detailBt = bt;
  152. }
  153. return _detailBt;
  154. }
  155. - (UIButton *)ruleBt {
  156. if (!_ruleBt) {
  157. UIButton *bt = [UIButton buttonWithType:UIButtonTypeCustom];
  158. NSMutableAttributedString *str = [[NSMutableAttributedString alloc] initWithString:@"Rules"];
  159. [str addAttributes:@{
  160. NSForegroundColorAttributeName:_0B0B0B,
  161. NSUnderlineStyleAttributeName: @(NSUnderlineStyleSingle),
  162. NSFontAttributeName:[UIFont fontWithName:Rob_Regular size:14]
  163. } range:NSMakeRange(0, str.length)];
  164. [bt setAttributedTitle:str forState:UIControlStateNormal];
  165. [bt addTarget:self action:@selector(ruleAction) forControlEvents:UIControlEventTouchUpInside];
  166. _ruleBt = bt;
  167. }
  168. return _ruleBt;
  169. }
  170. @end