// // StudentDetailInfoHeaderView.m // LN_Schooltr // // Created by 张嵘 on 2019/7/25. // Copyright © 2019 Danson. All rights reserved. // #import "StudentDetailInfoHeaderView.h" @interface StudentDetailInfoHeaderView () @property (nonatomic, readwrite, strong) UIImageView *backgroundView; @property (nonatomic, readwrite, strong) UIView *contentView; @property (nonatomic, readwrite, strong) UIImageView *headerImageView; @property (nonatomic, readwrite, strong) UILabel *nameLabel; @property (nonatomic, readwrite, strong) UILabel *sexLabel; @property (nonatomic, readwrite, strong) UILabel *driverSchoolLabel; @property (nonatomic, readwrite, strong) UILabel *phoneLabel; @property (nonatomic, readwrite, strong) YYLabel *remarkLabel; @end @implementation StudentDetailInfoHeaderView #pragma mark - Life Cycle - (instancetype)initWithFrame:(CGRect)frame { self = [super initWithFrame:frame]; if (self) { self.backgroundColor = UIColor.whiteColor; [self addSubview:self.backgroundView]; [self addSubview:self.contentView]; [self.contentView addSubview:self.headerImageView]; [self.contentView addSubview:self.nameLabel]; [self.contentView addSubview:self.sexLabel]; [self.contentView addSubview:self.driverSchoolLabel]; [self.contentView addSubview:self.phoneLabel]; [self.contentView addSubview:self.remarkLabel]; } return self; } - (void)layoutSubviews { [super layoutSubviews]; [_backgroundView mas_makeConstraints:^(MASConstraintMaker *make) { make.top.mas_offset(0); make.centerX.mas_equalTo(self); make.size.mas_equalTo(CGSizeMake(self.bounds.size.width, self.bounds.size.height * (1.f / 2.f))); }]; [_contentView mas_makeConstraints:^(MASConstraintMaker *make) { make.centerX.mas_equalTo(self); make.bottom.mas_offset(-10); make.size.mas_equalTo(CGSizeMake(self.bounds.size.width - (2 * 16), self.bounds.size.height * (2.f / 3.f))); }]; [_headerImageView mas_makeConstraints:^(MASConstraintMaker *make) { make.top.mas_offset(- self.bounds.size.width / 10.f); make.centerX.mas_equalTo(self.contentView); make.size.mas_equalTo(CGSizeMake(self.bounds.size.width / 5.f, self.bounds.size.width / 5.f)); }]; [_nameLabel mas_makeConstraints:^(MASConstraintMaker *make) { make.top.mas_equalTo(_headerImageView.mas_bottom).mas_offset(4); make.centerX.mas_equalTo(self.contentView); make.size.mas_equalTo(CGSizeMake(self.bounds.size.width - (2 * 16) - (2 * 8), ((self.bounds.size.height * (2.f / 3.f)) - self.bounds.size.width / 10.f - 40) / 3.f)); }]; [_sexLabel mas_makeConstraints:^(MASConstraintMaker *make) { make.top.mas_equalTo(_nameLabel.mas_bottom).mas_offset(8); make.left.mas_equalTo(self.contentView).mas_offset(8); make.size.mas_equalTo(CGSizeMake((self.bounds.size.width - (2 * 16) - (3 * 8)) / 2.f, ((self.bounds.size.height * (2.f / 3.f)) - self.bounds.size.width / 10.f - 28) / 3.f)); }]; [_driverSchoolLabel mas_makeConstraints:^(MASConstraintMaker *make) { make.top.mas_equalTo(_nameLabel.mas_bottom).mas_offset(8); make.right.mas_equalTo(self.contentView).mas_offset(- 8); make.size.mas_equalTo(CGSizeMake((self.bounds.size.width - (2 * 16) - (3 * 8)) / 2.f, ((self.bounds.size.height * (2.f / 3.f)) - self.bounds.size.width / 10.f - 28) / 3.f)); }]; [_phoneLabel mas_makeConstraints:^(MASConstraintMaker *make) { make.top.mas_equalTo(_sexLabel.mas_bottom).mas_offset(8); make.left.mas_equalTo(self.contentView).mas_offset(8); make.size.mas_equalTo(CGSizeMake((self.bounds.size.width - (2 * 16) - (3 * 8)) / 2.f, ((self.bounds.size.height * (2.f / 3.f)) - self.bounds.size.width / 10.f - 28) / 3.f)); }]; [_remarkLabel mas_makeConstraints:^(MASConstraintMaker *make) { make.top.mas_equalTo(_driverSchoolLabel.mas_bottom).mas_offset(8); make.right.mas_equalTo(self.contentView).mas_offset(- 8); make.size.mas_equalTo(CGSizeMake((self.bounds.size.width - (2 * 16) - (3 * 8)) / 2.f, ((self.bounds.size.height * (2.f / 3.f)) - self.bounds.size.width / 10.f - 28) / 3.f)); }]; } - (void)updateSecVUI:(__kindof HDSectionModel *)model { NSMutableAttributedString *remarkLabelAttStr = [[NSMutableAttributedString alloc] initWithString:_remarkLabel.text]; remarkLabelAttStr.yy_color = RQRedColor; [remarkLabelAttStr yy_setColor:RQContentTextColor range:[_remarkLabel.text rangeOfString:@"备注:"]]; remarkLabelAttStr.yy_font = [UIFont systemFontOfSize:15]; remarkLabelAttStr.yy_alignment = NSTextAlignmentCenter; _remarkLabel.attributedText = remarkLabelAttStr; } #pragma mark - Lazy Load - (UIImageView *)backgroundView { if (!_backgroundView) { _backgroundView = [[UIImageView alloc] initWithImage:[UIImage yy_imageWithColor:RQMianColor]]; } return _backgroundView; } - (UIView *)contentView { if (!_contentView) { _contentView = [[UIView alloc] init]; _contentView.backgroundColor = UIColor.whiteColor; _contentView.layer.cornerRadius = 5; _contentView.layer.masksToBounds = NO; _contentView.layer.shadowColor = [UIColor lightGrayColor].CGColor; _contentView.layer.shadowOffset = CGSizeMake(0, 0); _contentView.layer.shadowOpacity = 0.8; _contentView.layer.shadowRadius = 5; } return _contentView; } - (UIImageView *)headerImageView { if (!_headerImageView) { _headerImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"HeaderPlacehold"]]; _headerImageView.layer.borderWidth = 4; _headerImageView.layer.borderColor = UIColor.whiteColor.CGColor; _headerImageView.layer.cornerRadius = self.bounds.size.width / 10.f; _headerImageView.layer.masksToBounds = YES; } return _headerImageView; } - (UILabel *)nameLabel { if (!_nameLabel) { _nameLabel = [[UILabel alloc] init]; _nameLabel.text = @"张小凡"; _nameLabel.font = [UIFont systemFontOfSize:17]; _nameLabel.textAlignment = NSTextAlignmentCenter; _nameLabel.textColor = RQContentTextColor; } return _nameLabel; } - (UILabel *)sexLabel { if (!_sexLabel) { _sexLabel = [[UILabel alloc] init]; _sexLabel.text = @"性别:男"; _sexLabel.font = [UIFont systemFontOfSize:15]; _sexLabel.textAlignment = NSTextAlignmentCenter; _sexLabel.textColor = RQContentTextColor; } return _sexLabel; } - (UILabel *)driverSchoolLabel { if (!_driverSchoolLabel) { _driverSchoolLabel = [[UILabel alloc] init]; _driverSchoolLabel.text = @"驾校:金安驾校"; _driverSchoolLabel.font = [UIFont systemFontOfSize:15]; _driverSchoolLabel.textAlignment = NSTextAlignmentCenter; _driverSchoolLabel.textColor = RQContentTextColor; } return _driverSchoolLabel; } - (UILabel *)phoneLabel { if (!_phoneLabel) { _phoneLabel = [[UILabel alloc] init]; _phoneLabel.text = @"电话:15978657321"; _phoneLabel.font = [UIFont systemFontOfSize:15]; _phoneLabel.textAlignment = NSTextAlignmentCenter; _phoneLabel.textColor = RQContentTextColor; } return _phoneLabel; } - (YYLabel *)remarkLabel { if (!_remarkLabel) { _remarkLabel = [[YYLabel alloc] init]; _remarkLabel.text = @"备注:已考过"; _remarkLabel.font = [UIFont systemFontOfSize:15]; _remarkLabel.textAlignment = NSTextAlignmentCenter; _remarkLabel.textColor = RQRedColor; } return _remarkLabel; } @end