// // HomePageSectionThreeHeaderView.m // LN_School // // Created by 张嵘 on 2019/7/17. // Copyright © 2019 Danson. All rights reserved. // #import "HomePageSectionThreeHeaderView.h" #import "UIView+gesture.h" #import "HomePageSecHeaderModel.h" @interface HomePageSectionThreeHeaderView () @property (nonatomic, readwrite, strong) UIView *contentView; @property (nonatomic, readwrite, strong) UILabel *titleLabel; @property (nonatomic, readwrite, strong) UILabel *rightTitleLabel; @property (nonatomic, readwrite, strong) UIImageView *arrowImageView; @property (nonatomic, readwrite, strong) UIImageView *titleIconImageView; @end @implementation HomePageSectionThreeHeaderView #pragma mark - Life Cycle - (instancetype)initWithFrame:(CGRect)frame { self = [super initWithFrame:frame]; if (self) { [self addSubview:self.contentView]; [self.contentView addSubview:self.titleIconImageView]; [self.contentView addSubview:self.titleLabel]; [self.contentView addSubview:self.rightTitleLabel]; [self.contentView addSubview:self.arrowImageView]; } __weak typeof (self) weakS = self; [self.contentView addTapActionWithBlock:^(UIGestureRecognizer *gestureRecoginzer) { [weakS clickSelf]; }]; return self; } - (void)layoutSubviews { [super layoutSubviews]; [_contentView mas_makeConstraints:^(MASConstraintMaker *make) { make.left.top.right.mas_offset(0); make.size.mas_equalTo(CGSizeMake(self.bounds.size.width, self.bounds.size.height)); }]; [_titleIconImageView mas_makeConstraints:^(MASConstraintMaker *make) { make.centerY.mas_equalTo(self.contentView); make.left.mas_offset(16); make.size.mas_equalTo(CGSizeMake(5, self.bounds.size.height * 0.4)); }]; [_titleLabel mas_makeConstraints:^(MASConstraintMaker *make) { make.centerY.mas_equalTo(self.contentView); make.left.mas_equalTo(_titleIconImageView.mas_right).mas_offset(8); make.size.mas_equalTo(CGSizeMake(self.bounds.size.width * 0.3, self.bounds.size.height)); }]; [_arrowImageView mas_makeConstraints:^(MASConstraintMaker *make) { make.centerY.mas_equalTo(self.contentView); make.right.mas_offset(-10); make.size.mas_equalTo(CGSizeMake((17.0 / 28.0) * self.bounds.size.height * 0.3, self.bounds.size.height * 0.3)); }]; [_rightTitleLabel mas_makeConstraints:^(MASConstraintMaker *make) { make.centerY.mas_equalTo(self.contentView); make.right.mas_equalTo(_arrowImageView.mas_left).mas_offset(-4); make.size.mas_equalTo(CGSizeMake(self.bounds.size.width * 0.2, self.bounds.size.height)); }]; } #pragma mark - Private Functions - (void)updateSecVUI:(__kindof HDSectionModel *)model { HomePageSecHeaderModel *headerModel = model.headerObj; _titleLabel.text = headerModel.title; _rightTitleLabel.text = @"更多"; } - (void)clickSelf { self.callback(self.hdSecModel); } #pragma mark - LazyLoad -(UIView *)contentView { if (!_contentView) { _contentView = [[UIView alloc] init]; _contentView.backgroundColor = UIColor.whiteColor; } return _contentView; } - (UILabel *)titleLabel { if (!_titleLabel) { _titleLabel = [UILabel new]; _titleLabel.font = [UIFont systemFontOfSize:17]; _titleLabel.textAlignment = NSTextAlignmentLeft; } return _titleLabel; } - (UILabel *)rightTitleLabel { if (!_rightTitleLabel) { _rightTitleLabel = [UILabel new]; _rightTitleLabel.font = [UIFont systemFontOfSize:15]; _rightTitleLabel.textAlignment = NSTextAlignmentRight; _rightTitleLabel.textColor = UIColor.lightGrayColor; } return _rightTitleLabel; } - (UIImageView *)titleIconImageView { if (!_titleIconImageView) { _titleIconImageView = [[UIImageView alloc] init]; _titleIconImageView.backgroundColor = RQSubColor; _titleIconImageView.layer.cornerRadius = 2.5; _titleIconImageView.clipsToBounds = YES; } return _titleIconImageView; } - (UIImageView *)arrowImageView { if (!_arrowImageView) { _arrowImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"ArrowLight"]]; } return _arrowImageView; } @end