説明なし

KXTeachCollectionViewCell.m 1.4KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. //
  2. // KXTeachCollectionViewCell.m
  3. // CAISHEN
  4. //
  5. // Created by kuxuan on 2017/11/1.
  6. // Copyright © 2017年 kuxuan. All rights reserved.
  7. //
  8. #import "KXTeachCollectionViewCell.h"
  9. @implementation KXTeachCollectionViewCell
  10. {
  11. UIImageView *_thumbImageView;
  12. UILabel *_titleLabel;
  13. }
  14. - (instancetype)initWithFrame:(CGRect)frame
  15. {
  16. if (self == [super initWithFrame:frame]) {
  17. [self setupUI];
  18. }
  19. return self;
  20. }
  21. - (void)setupUI
  22. {
  23. _thumbImageView = [[UIImageView alloc]init];
  24. [self.contentView addSubview:_thumbImageView];
  25. _titleLabel = [[UILabel alloc]init];
  26. _titleLabel.textAlignment = NSTextAlignmentCenter;
  27. _titleLabel.font = FONT_SYS(12);
  28. _titleLabel.textColor = [UIColor titleColor];
  29. [self.contentView addSubview:_titleLabel];
  30. [_thumbImageView mas_makeConstraints:^(MASConstraintMaker *make) {
  31. make.top.left.right.equalTo(self.contentView);
  32. make.height.mas_equalTo(80);
  33. }];
  34. [_titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  35. make.top.equalTo(_thumbImageView.mas_bottom);
  36. make.left.right.bottom.equalTo(self.contentView);
  37. }];
  38. }
  39. - (void)setNewsModel:(KXNewsModel *)newsModel
  40. {
  41. _newsModel = newsModel;
  42. [_thumbImageView sd_setImageWithURL:[NSURL URLWithString:newsModel.thumbnail] placeholderImage:[UIImage imageNamed:@"placeholder_square"] options:0];
  43. _titleLabel.text = newsModel.sub_title;
  44. }
  45. @end