// // TrainSummaryHeaderView.m // LN_School // // Created by 张嵘 on 2019/7/26. // Copyright © 2019 Danson. All rights reserved. // #import "TrainSummaryHeaderView.h" @interface TrainSummaryHeaderView () @property (nonatomic, readwrite, strong) UIView *contentView; @property (nonatomic, readwrite, strong) UILabel *carTypeTitleLabel; @property (nonatomic, readwrite, strong) UILabel *carTypeContentLabel; @property (nonatomic, readwrite, strong) UILabel *driverHoursTitleLabel; @property (nonatomic, readwrite, strong) UILabel *driverHoursContentLabel; @property (nonatomic, readwrite, strong) UIImageView *centerLineView; @end @implementation TrainSummaryHeaderView #pragma mark - Life Cycle - (instancetype)initWithFrame:(CGRect)frame { self = [super initWithFrame:frame]; if (self) { self.backgroundColor = RQMianColor; [self addSubview:self.contentView]; [self.contentView addSubview:self.carTypeTitleLabel]; [self.contentView addSubview:self.carTypeContentLabel]; [self.contentView addSubview:self.driverHoursTitleLabel]; [self.contentView addSubview:self.driverHoursContentLabel]; [self.contentView addSubview:self.centerLineView]; } return self; } - (void)layoutSubviews { [super layoutSubviews]; [_contentView mas_makeConstraints:^(MASConstraintMaker *make) { make.center.mas_equalTo(self); make.size.mas_equalTo(CGSizeMake(self.bounds.size.width, self.bounds.size.height * 2.f / 3.f)); }]; [_carTypeTitleLabel mas_makeConstraints:^(MASConstraintMaker *make) { make.top.left.mas_offset(0); make.size.mas_equalTo(CGSizeMake(self.bounds.size.width * 0.5, self.bounds.size.height / 3.f)); }]; [_carTypeContentLabel mas_makeConstraints:^(MASConstraintMaker *make) { make.left.bottom.mas_offset(0); make.size.mas_equalTo(_carTypeTitleLabel); }]; [_driverHoursTitleLabel mas_makeConstraints:^(MASConstraintMaker *make) { make.top.right.mas_offset(0); make.size.mas_equalTo(_carTypeTitleLabel); }]; [_driverHoursContentLabel mas_makeConstraints:^(MASConstraintMaker *make) { make.bottom.right.mas_offset(0); make.size.mas_equalTo(_carTypeTitleLabel); }]; [_centerLineView mas_makeConstraints:^(MASConstraintMaker *make) { make.center.mas_equalTo(_contentView); make.size.mas_equalTo(CGSizeMake(1, self.bounds.size.height / 3.f)); }]; } #pragma mark - HDUpdateUIProtocol - (void)updateCellUI:(__kindof HDCellModel *)model { // TrainRecordModel *trainRecordModel = model.orgData; // [self.headImageView sd_setImageWithURL:[NSURL URLWithString:trainRecordModel.url? : @""] placeholderImage:[UIImage imageNamed:@"HeaderPlacehold"]]; // self.timeLabel.text = [NSString stringWithFormat:@"时间:%@",trainRecordModel.time]; // self.stageLabel.text = [NSString stringWithFormat:@"阶段:%@",trainRecordModel.stage]; // self.driverObjectLabel.text = [NSString stringWithFormat:@"类型:%@",trainRecordModel.object]; // self.driverHoursLabel.text = [NSString stringWithFormat:@"学时:%@",trainRecordModel.hour]; } #pragma mark - Lazy Load - (UIView *)contentView { if (!_contentView) { _contentView = [[UIView alloc] init]; _contentView.backgroundColor = RQMianColor; } return _contentView; } - (UILabel *)carTypeTitleLabel { if (!_carTypeTitleLabel) { _carTypeTitleLabel = [[UILabel alloc] init]; _carTypeTitleLabel.text = @"培训车型"; _carTypeTitleLabel.textAlignment = NSTextAlignmentCenter; _carTypeTitleLabel.textColor = UIColor.whiteColor; _carTypeTitleLabel.numberOfLines = 0; _carTypeTitleLabel.font = [UIFont systemFontOfSize:18]; } return _carTypeTitleLabel; } - (UILabel *)carTypeContentLabel { if (!_carTypeContentLabel) { _carTypeContentLabel = [[UILabel alloc] init]; _carTypeContentLabel.text = @"C1"; _carTypeContentLabel.textAlignment = NSTextAlignmentCenter; _carTypeContentLabel.textColor = UIColor.whiteColor; _carTypeContentLabel.numberOfLines = 0; _carTypeContentLabel.font = [UIFont systemFontOfSize:18]; } return _carTypeContentLabel; } - (UILabel *)driverHoursTitleLabel { if (!_driverHoursTitleLabel) { _driverHoursTitleLabel = [[UILabel alloc] init]; _driverHoursTitleLabel.text = @"培训学时"; _driverHoursTitleLabel.textAlignment = NSTextAlignmentCenter; _driverHoursTitleLabel.textColor = UIColor.whiteColor; _driverHoursTitleLabel.numberOfLines = 0; _driverHoursTitleLabel.font = [UIFont systemFontOfSize:18]; } return _driverHoursTitleLabel; } - (UILabel *)driverHoursContentLabel { if (!_driverHoursContentLabel) { _driverHoursContentLabel = [[UILabel alloc] init]; _driverHoursContentLabel.text = @"62"; _driverHoursContentLabel.textAlignment = NSTextAlignmentCenter; _driverHoursContentLabel.textColor = UIColor.whiteColor; _driverHoursContentLabel.numberOfLines = 0; _driverHoursContentLabel.font = [UIFont systemFontOfSize:18]; } return _driverHoursContentLabel; } - (UIImageView *)centerLineView { if (!_centerLineView) { _centerLineView = [[UIImageView alloc] init]; _centerLineView.backgroundColor = RQColorFromHexString(@"6482cf"); } return _centerLineView; } @end