// // ASPointHeadView.m // Asteria // // Created by iOS on 2023/6/19. // #import "ASPointHeadView.h" @interface ASPointHeadView () @property (nonatomic, strong) UIView *topBgV; @property (nonatomic, strong) UIView *bottomBgV; @property (nonatomic, strong) UILabel *numLb; @property (nonatomic, strong) UILabel *numDesLb; @property (nonatomic, strong) UIButton *detailBt; @property (nonatomic, strong) UIButton *ruleBt; @property (nonatomic, strong) UILabel *bottomTitleLb; @end @implementation ASPointHeadView - (void)setData:(NSString *)num { self.numLb.text = num; } - (void)ruleAction { if (self.ruleCallBack) { self.ruleCallBack(); } } - (void)detailAction { if (self.detailCallBack) { self.detailCallBack(); } } - (instancetype)initWithFrame:(CGRect)frame { CGRect rect = CGRectMake(0, 0, KScreenWidth, 205); self = [super initWithFrame:rect]; if (self) { [self loadsubV]; } return self; } - (void)loadsubV { self.backgroundColor = _E0FFF5; [self addSubview:self.topBgV]; [self addSubview:self.bottomBgV]; [self.topBgV addSubview:self.numLb]; [self.topBgV addSubview:self.numDesLb]; [self.topBgV addSubview:self.detailBt]; [self.topBgV addSubview:self.ruleBt]; [self.bottomBgV addSubview:self.bottomTitleLb]; [self.bottomBgV mas_makeConstraints:^(MASConstraintMaker *make) { make.height.equalTo(@70); make.bottom.leading.trailing.equalTo(self); }]; [self.topBgV mas_makeConstraints:^(MASConstraintMaker *make) { make.top.leading.trailing.equalTo(self); make.height.equalTo(@135); }]; [self.numLb mas_makeConstraints:^(MASConstraintMaker *make) { make.leading.equalTo(self.topBgV).offset(30); make.height.equalTo(@58); make.top.equalTo(self.topBgV).offset(30); }]; [self.numDesLb mas_makeConstraints:^(MASConstraintMaker *make) { make.leading.equalTo(self.numLb); make.top.equalTo(self.numLb.mas_bottom); make.height.equalTo(@17); }]; [self.ruleBt mas_makeConstraints:^(MASConstraintMaker *make) { make.width.equalTo(@44); make.top.equalTo(self.topBgV).offset(30); make.trailing.equalTo(self.topBgV).offset(-15); make.height.equalTo(@17); }]; [self.detailBt mas_makeConstraints:^(MASConstraintMaker *make) { make.height.equalTo(self.ruleBt); make.width.equalTo(@53); make.trailing.equalTo(self.ruleBt.mas_leading).offset(0); make.centerY.equalTo(self.ruleBt); }]; [self.bottomTitleLb mas_makeConstraints:^(MASConstraintMaker *make) { make.top.equalTo(self.bottomBgV).offset(30); make.leading.equalTo(self.bottomBgV).offset(20); make.trailing.equalTo(self.bottomBgV).offset(-20); make.height.equalTo(@30); }]; } - (UIView *)topBgV { if (!_topBgV) { UIView *v = [UIView baseV]; v.backgroundColor = _E0FFF5; _topBgV = v; } return _topBgV; } - (UIView *)bottomBgV { if (!_bottomBgV) { UIView *v = [UIView baseV]; v.frame = CGRectMake(0, 0, KScreenWidth, 70); v.backgroundColor = Col_FFF; // 左上和右上为圆角 UIBezierPath *cornerRadiusPath = [UIBezierPath bezierPathWithRoundedRect:v.bounds byRoundingCorners:UIRectCornerTopRight | UIRectCornerTopLeft cornerRadii:CGSizeMake(16, 16)]; CAShapeLayer *cornerRadiusLayer = [ [CAShapeLayer alloc ] init]; cornerRadiusLayer.frame = v.bounds; cornerRadiusLayer.path = cornerRadiusPath.CGPath; v.layer.mask = cornerRadiusLayer; _bottomBgV = v; } return _bottomBgV; } - (UILabel *)bottomTitleLb { if (!_bottomTitleLb) { UILabel *lb = [UILabel baseLb]; lb.font = [UIFont fontWithName:Rob_Bold size:24]; lb.textColor = Col_000; lb.textAlignment = NSTextAlignmentLeft; lb.text = @"ERAN POINTS"; _bottomTitleLb = lb; } return _bottomTitleLb; } - (UILabel *)numLb { if (!_numLb) { UILabel *lb = [UILabel baseLb]; lb.font = [UIFont fontWithName:Rob_Bold size:48]; lb.textColor = Col_000; lb.textAlignment = NSTextAlignmentLeft; _numLb = lb; } return _numLb; } - (UILabel *)numDesLb { if (!_numDesLb) { UILabel *lb = [UILabel baseLb]; lb.font = [UIFont fontWithName:Rob_Regular size:14]; lb.textColor = Col_000; lb.textAlignment = NSTextAlignmentLeft; lb.text = @"My Points"; _numDesLb = lb; } return _numDesLb; } - (UIButton *)detailBt { if (!_detailBt) { UIButton *bt = [UIButton buttonWithType:UIButtonTypeCustom]; NSMutableAttributedString *str = [[NSMutableAttributedString alloc] initWithString:@"Details"]; [str addAttributes:@{ NSForegroundColorAttributeName:_0B0B0B, NSUnderlineStyleAttributeName: @(NSUnderlineStyleSingle), NSFontAttributeName:[UIFont fontWithName:Rob_Regular size:14] } range:NSMakeRange(0, str.length)]; [bt setAttributedTitle:str forState:UIControlStateNormal]; [bt addTarget:self action:@selector(detailAction) forControlEvents:UIControlEventTouchUpInside]; _detailBt = bt; } return _detailBt; } - (UIButton *)ruleBt { if (!_ruleBt) { UIButton *bt = [UIButton buttonWithType:UIButtonTypeCustom]; NSMutableAttributedString *str = [[NSMutableAttributedString alloc] initWithString:@"Rules"]; [str addAttributes:@{ NSForegroundColorAttributeName:_0B0B0B, NSUnderlineStyleAttributeName: @(NSUnderlineStyleSingle), NSFontAttributeName:[UIFont fontWithName:Rob_Regular size:14] } range:NSMakeRange(0, str.length)]; [bt setAttributedTitle:str forState:UIControlStateNormal]; [bt addTarget:self action:@selector(ruleAction) forControlEvents:UIControlEventTouchUpInside]; _ruleBt = bt; } return _ruleBt; } @end