12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879 |
- //
- // ShowPhotoesCell.m
- // LN_School
- //
- // Created by 张嵘 on 2019/7/28.
- // Copyright © 2019 Danson. All rights reserved.
- //
- #import "ShowPhotoesCell.h"
- #import "ShowPhotoesModel.h"
- @interface ShowPhotoesCell ()
- @property (nonatomic, readwrite, strong) UILabel *titleLabel;
- @property (nonatomic, readwrite, strong) UIImageView *imageView;
- @end
- @implementation ShowPhotoesCell
- #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.top.mas_offset(0);
- make.centerX.mas_equalTo(self.contentView);
- make.size.mas_equalTo(CGSizeMake(self.bounds.size.width, self.bounds.size.width));
- }];
- [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.mas_equalTo(self.imageView.mas_bottom).mas_offset(0);
- make.centerX.mas_equalTo(self.contentView);
- make.size.mas_equalTo(CGSizeMake(self.bounds.size.width, self.bounds.size.width * 0.2));
- }];
- [super layoutSubviews];
- }
- #pragma mark - Private Functions
- - (void)updateCellUI:(__kindof HDCellModel *)model {
- if ([model.orgData isKindOfClass:[ShowPhotoesModel class]]) {
- ShowPhotoesModel *showPhotoesModel = model.orgData;
- [_imageView sd_setImageWithURL:[NSURL URLWithString:showPhotoesModel.url? :@""] placeholderImage:[UIImage imageNamed:@""]];
- _titleLabel.text = showPhotoesModel.name? : @"";
- }
- }
- - (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
|