// // HomePageSecHeaderView.m // LN_School // // Created by 张嵘 on 2019/7/9. // Copyright © 2019 Danson. All rights reserved. // #import "HomePageSecHeaderView.h" #import "UIView+gesture.h" #import "HomePageSecHeaderModel.h" @interface HomePageSecHeaderView () @property (nonatomic, readwrite, strong) UIView *contentView; @property (nonatomic, readwrite, strong) UILabel *rightTitleLabel; @property (nonatomic, readwrite, strong) UIImageView *arrowImageView; @property (nonatomic, readwrite, strong) UIImageView *titleIconImageView; @end @implementation HomePageSecHeaderView #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]; if (![self.subviews containsObject:[self rootView].jxTitle]) { [self insertSubview:self.rootView.jxTitle atIndex:0]; } [_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 * 0.5)); }]; [_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.2)); }]; [_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 * 0.5)); }]; [_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.15, self.bounds.size.height * 0.15)); }]; [_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 * 0.5)); }]; // [self.rootView.jxTitle mas_makeConstraints:^(MASConstraintMaker *make) { // make.left.bottom.right.mas_offset(0); // make.size.mas_equalTo(CGSizeMake(self.bounds.size.width, self.bounds.size.height * 0.5)); // }]; self.rootView.jxTitle.frame = CGRectMake(0, self.bounds.size.height / 3.0, self.bounds.size.width, self.bounds.size.height / 2.0 + ((self.bounds.size.height / 2.0) - (self.bounds.size.height / 3.0 ))); } #pragma mark - Private Functions - (void)updateSecVUI:(__kindof HDSectionModel *)model { HomePageSecHeaderModel *headerModel = model.headerObj; _titleLabel.text = @"报名情况"; _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