1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980 |
- //
- // HomePageSecOneCell.m
- // LN_School
- //
- // Created by 张嵘 on 2019/7/9.
- // Copyright © 2019 Danson. All rights reserved.
- //
- #import "HomePageSecOneCell.h"
- #import "UIView+gesture.h"
- #import "HomePageSecOneModel.h"
- @interface HomePageSecOneCell ()
- @property (nonatomic, readwrite, strong) UILabel *titleLabel;
- @property (nonatomic, readwrite, strong) UIImageView *imageView;
- @end
- @implementation HomePageSecOneCell
- #pragma mark - Life Cycle
- - (instancetype)initWithFrame:(CGRect)frame {
- self = [super initWithFrame:frame];
- if (self) {
- self.contentView.backgroundColor = UIColor.whiteColor;
- [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:[HomePageSecOneModel class]]) {
- HomePageSecOneModel *homePageSecOneModel = model.orgData;
- self.titleLabel.text = homePageSecOneModel.title;
- self.imageView.image = [UIImage imageNamed:homePageSecOneModel.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
|