// // MyTDTopicCellView.m // smartRhino // // Created by tederen on 2019/10/31. // Copyright © 2019 tederen. All rights reserved. // #import "MyTDTopicCellView.h" #import "MyTDTopicModel.h" #import "MyTDTopicModelSub.h" @interface MyTDTopicCellView() @property (nonatomic, strong) UIView *myBackgroundView; @property (nonatomic, strong) UIImageView *articlaImage; @property (nonatomic, strong) UILabel *articleNamelab; @property (nonatomic, strong) UILabel *articleContentLab; @property (nonatomic, strong) UILabel *sourceLab; @property (nonatomic, strong) TDButton *closeButton; @end @implementation MyTDTopicCellView - (void)loadTopicData:(MyTDTopicModel *)model{ MyTDTopicModelSub *mymodel = model.noteArray.firstObject; self.articlaImage.image = mymodel.noteImage; self.articleNamelab.text = mymodel.noteTitle; self.articleContentLab.text = mymodel.noteContent; [ZYCTool setLabel:self.articleContentLab withSpace:1 withFont:[UIFont systemFontOfSize:12.f] setLineSpace:0 setTextSpace:0.1]; self.sourceLab.text = mymodel.noteSource; CGRect frame = self.frame; frame.size.height = 110; self.frame = frame; // self.closeButton } - (instancetype)initWithFrame:(CGRect)frame { self = [super initWithFrame:frame]; if (self) { [self addSubview:self.myBackgroundView]; [self.myBackgroundView mas_makeConstraints:^(MASConstraintMaker *make) { make.left.right.equalTo(self).offset(15); make.right.equalTo(self).offset(-15); make.top.equalTo(self); make.height.mas_equalTo(90); }]; [self.myBackgroundView addSubview:self.articlaImage]; [self.articlaImage mas_makeConstraints:^(MASConstraintMaker *make) { make.left.equalTo(self.myBackgroundView).offset(10); make.top.equalTo(self.myBackgroundView).offset(20); make.width.height.mas_equalTo(50); }]; [self.myBackgroundView addSubview:self.articleNamelab]; [self.articleNamelab mas_makeConstraints:^(MASConstraintMaker *make) { make.left.equalTo(self.articlaImage.mas_right).offset(10); make.top.equalTo(self.myBackgroundView).offset(10); make.right.equalTo(self.myBackgroundView).offset(-35); make.height.mas_equalTo(15); }]; [self.myBackgroundView addSubview:self.articleContentLab]; [self.articleContentLab mas_makeConstraints:^(MASConstraintMaker *make) { make.left.equalTo(self.articlaImage.mas_right).offset(10); make.top.equalTo(self.articleNamelab.mas_bottom).offset(10); make.right.equalTo(self.myBackgroundView).offset(-35); make.height.mas_equalTo(30); }]; [self.myBackgroundView addSubview:self.sourceLab]; [self.sourceLab mas_makeConstraints:^(MASConstraintMaker *make) { make.left.equalTo(self.articlaImage.mas_right).offset(10); make.top.equalTo(self.articleContentLab.mas_bottom).offset(5); }]; [self.myBackgroundView addSubview:self.closeButton]; [self.closeButton mas_makeConstraints:^(MASConstraintMaker *make) { make.right.equalTo(self.myBackgroundView).offset(-10); make.top.equalTo(self.myBackgroundView).offset(10); make.width.height.mas_equalTo(10); }]; } return self; } - (UIImageView *)articlaImage{ if (!_articlaImage) { _articlaImage = [UIImageView new]; } return _articlaImage; } - (UILabel *)articleNamelab{ if (!_articleNamelab) { _articleNamelab = [UILabel new]; _articleNamelab.textColor = UIColorHex(333333); _articleNamelab.font = [UIFont systemFontOfSize:15.f weight:UIFontWeightLight]; } return _articleNamelab; } - (UILabel *)articleContentLab{ if (!_articleContentLab) { _articleContentLab = [UILabel new]; _articleContentLab.textColor = UIColorHex(999999); _articleContentLab.font = [UIFont systemFontOfSize:12.f weight:UIFontWeightLight]; _articleContentLab.numberOfLines = 0; } return _articleContentLab; } - (UILabel *)sourceLab{ if (!_sourceLab) { _sourceLab = [UILabel new]; _sourceLab.textColor = UIColorHex(999999); _sourceLab.font = [UIFont systemFontOfSize:12.f weight:UIFontWeightLight]; _sourceLab.textAlignment = NSTextAlignmentLeft; _sourceLab.numberOfLines = 0; } return _sourceLab; } - (TDButton *)closeButton{ if (!_closeButton) { _closeButton = [[TDButton alloc]init]; [_closeButton setImage:IMG(@"叉号") forState:UIControlStateNormal]; [_closeButton setCurrentButtonHotSize:CGSizeZero]; } return _closeButton; } - (UIView *)myBackgroundView{ if (!_myBackgroundView){ _myBackgroundView = [UIView new]; _myBackgroundView.backgroundColor = UIColorHex(F4F5F5); } return _myBackgroundView; } @end