// // TrainSituationNumHeaderView.m // LN_School // // Created by 张嵘 on 2019/7/17. // Copyright © 2019 Danson. All rights reserved. // #import "TrainSituationNumHeaderView.h" #import "TrainSituationNumHeaderModel.h" @interface TrainSituationNumHeaderView () @property (nonatomic, readwrite, strong) UIButton *signUpNumBtn; @property (nonatomic, readwrite, strong) UIButton *trainNumBtn; @end @implementation TrainSituationNumHeaderView #pragma mark - Life Cycle - (instancetype)initWithFrame:(CGRect)frame { self = [super initWithFrame:frame]; if (self) { self.backgroundColor = UIColor.whiteColor; [self addSubview:self.signUpNumBtn]; [self addSubview:self.trainNumBtn]; } return self; } - (void)layoutSubviews { [super layoutSubviews]; [_signUpNumBtn mas_makeConstraints:^(MASConstraintMaker *make) { make.left.mas_offset(24); make.centerY.mas_equalTo(self); make.size.mas_equalTo(CGSizeMake((kScreenWidth - 72) / 2.f, self.bounds.size.height * 0.6)); _signUpNumBtn.layer.cornerRadius = self.bounds.size.height * 0.3; }]; [_trainNumBtn mas_makeConstraints:^(MASConstraintMaker *make) { make.left.mas_equalTo(_signUpNumBtn.mas_right).mas_offset(24); make.centerY.mas_equalTo(self); make.size.mas_equalTo(CGSizeMake((kScreenWidth - 72) / 2.f, self.bounds.size.height * 0.6)); _trainNumBtn.layer.cornerRadius = self.bounds.size.height * 0.3; }]; } #pragma mark - Private Functions - (void)updateSecVUI:(__kindof HDSectionModel *)model { TrainSituationNumHeaderModel *headerModel = model.headerObj; _signUpNumBtn.hidden = !headerModel.leftLabelText; _trainNumBtn.hidden = !headerModel.rightLabelText; [_signUpNumBtn setTitle:headerModel.leftLabelText? : @"" forState:UIControlStateNormal]; [_trainNumBtn setTitle:headerModel.rightLabelText? : @"" forState:UIControlStateNormal]; } #pragma mark - LazyLoad - (UIButton *)signUpNumBtn { if (!_signUpNumBtn) { _signUpNumBtn = [UIButton buttonWithType:UIButtonTypeCustom]; [_signUpNumBtn setTitle:@"" forState:UIControlStateNormal]; _signUpNumBtn.titleLabel.font = [UIFont systemFontOfSize:13]; _signUpNumBtn.titleLabel.textAlignment = NSTextAlignmentLeft; _signUpNumBtn.titleLabel.textColor = UIColor.whiteColor; _signUpNumBtn.backgroundColor = RQPinkBlueColor; _signUpNumBtn.clipsToBounds = YES; } return _signUpNumBtn; } - (UIButton *)trainNumBtn { if (!_trainNumBtn) { _trainNumBtn = [UIButton buttonWithType:UIButtonTypeCustom]; [_trainNumBtn setTitle:@"" forState:UIControlStateNormal]; _trainNumBtn.titleLabel.font = [UIFont systemFontOfSize:13]; _trainNumBtn.titleLabel.textAlignment = NSTextAlignmentLeft; _trainNumBtn.titleLabel.textColor = UIColor.whiteColor; _trainNumBtn.backgroundColor = RQPinkGreenColor; _trainNumBtn.clipsToBounds = YES; } return _trainNumBtn; } @end