// // StudentDetailSecOneCell.m // LN_School // // Created by 张嵘 on 2019/7/25. // Copyright © 2019 Danson. All rights reserved. // #import "StudentDetailSecOneCell.h" #import "StudentDetailSecOneModel.h" @interface StudentDetailSecOneCell () @property (nonatomic, readwrite, strong) UILabel *titleLabel; @property (nonatomic, readwrite, strong) UIImageView *imageView; @end @implementation StudentDetailSecOneCell #pragma mark - Life Cycle - (instancetype)initWithFrame:(CGRect)frame { self = [super initWithFrame:frame]; if (self) { [self.contentView addSubview:self.imageView]; [self.contentView addSubview:self.titleLabel]; } __weak typeof(self) weakS = self; [self addTapActionWithBlock:^(UIGestureRecognizer *gestureRecoginzer) { [weakS clickSelf]; }]; return self; } - (void)layoutSubviews { [self.imageView mas_makeConstraints:^(MASConstraintMaker *make) { make.centerX.mas_equalTo(self.contentView); make.centerY.mas_equalTo(self.contentView).mas_offset(-10); make.height.width.mas_equalTo(self.bounds.size.width *0.5); }]; [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) { make.top.mas_equalTo(self.imageView.mas_bottom).mas_offset(0); make.centerX.mas_equalTo(self.contentView); make.height.mas_equalTo(self.bounds.size.width *0.33); }]; [super layoutSubviews]; } #pragma mark - Private Functions - (void)updateCellUI:(__kindof HDCellModel *)model { if ([model.orgData isKindOfClass:[StudentDetailSecOneModel class]]) { StudentDetailSecOneModel *studentDetailSecOneModel = model.orgData; self.titleLabel.text = studentDetailSecOneModel.title; self.imageView.image = [UIImage imageNamed:studentDetailSecOneModel.imageName]; } } - (void)clickSelf { self.callback(self.hdModel); } #pragma mark - Lazy Load - (UILabel *)titleLabel { if (!_titleLabel) { _titleLabel = [[UILabel alloc] init]; _titleLabel.textAlignment = NSTextAlignmentCenter; _titleLabel.numberOfLines = 0; _titleLabel.font = [UIFont systemFontOfSize:14]; _titleLabel.textColor = RQTitleTextColor; } return _titleLabel; } - (UIImageView *)imageView { if (!_imageView) { _imageView = [[UIImageView alloc] init]; } return _imageView; } @end