MyTDTopicCellView.m 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. //
  2. // MyTDTopicCellView.m
  3. // smartRhino
  4. //
  5. // Created by tederen on 2019/10/31.
  6. // Copyright © 2019 tederen. All rights reserved.
  7. //
  8. #import "MyTDTopicCellView.h"
  9. #import "MyTDTopicModel.h"
  10. #import "MyTDTopicModelSub.h"
  11. @interface MyTDTopicCellView()
  12. @property (nonatomic, strong) UIView *myBackgroundView;
  13. @property (nonatomic, strong) UIImageView *articlaImage;
  14. @property (nonatomic, strong) UILabel *articleNamelab;
  15. @property (nonatomic, strong) UILabel *articleContentLab;
  16. @property (nonatomic, strong) UILabel *sourceLab;
  17. @property (nonatomic, strong) TDButton *closeButton;
  18. @end
  19. @implementation MyTDTopicCellView
  20. - (void)loadTopicData:(MyTDTopicModel *)model{
  21. MyTDTopicModelSub *mymodel = model.noteArray.firstObject;
  22. self.articlaImage.image = mymodel.noteImage;
  23. self.articleNamelab.text = mymodel.noteTitle;
  24. self.articleContentLab.text = mymodel.noteContent;
  25. [ZYCTool setLabel:self.articleContentLab withSpace:1 withFont:[UIFont systemFontOfSize:12.f] setLineSpace:0 setTextSpace:0.1];
  26. self.sourceLab.text = mymodel.noteSource;
  27. CGRect frame = self.frame;
  28. frame.size.height = 110;
  29. self.frame = frame;
  30. // self.closeButton
  31. }
  32. - (instancetype)initWithFrame:(CGRect)frame
  33. {
  34. self = [super initWithFrame:frame];
  35. if (self) {
  36. [self addSubview:self.myBackgroundView];
  37. [self.myBackgroundView mas_makeConstraints:^(MASConstraintMaker *make) {
  38. make.left.right.equalTo(self).offset(15);
  39. make.right.equalTo(self).offset(-15);
  40. make.top.equalTo(self);
  41. make.height.mas_equalTo(90);
  42. }];
  43. [self.myBackgroundView addSubview:self.articlaImage];
  44. [self.articlaImage mas_makeConstraints:^(MASConstraintMaker *make) {
  45. make.left.equalTo(self.myBackgroundView).offset(10);
  46. make.top.equalTo(self.myBackgroundView).offset(20);
  47. make.width.height.mas_equalTo(50);
  48. }];
  49. [self.myBackgroundView addSubview:self.articleNamelab];
  50. [self.articleNamelab mas_makeConstraints:^(MASConstraintMaker *make) {
  51. make.left.equalTo(self.articlaImage.mas_right).offset(10);
  52. make.top.equalTo(self.myBackgroundView).offset(10);
  53. make.right.equalTo(self.myBackgroundView).offset(-35);
  54. make.height.mas_equalTo(15);
  55. }];
  56. [self.myBackgroundView addSubview:self.articleContentLab];
  57. [self.articleContentLab mas_makeConstraints:^(MASConstraintMaker *make) {
  58. make.left.equalTo(self.articlaImage.mas_right).offset(10);
  59. make.top.equalTo(self.articleNamelab.mas_bottom).offset(10);
  60. make.right.equalTo(self.myBackgroundView).offset(-35);
  61. make.height.mas_equalTo(30);
  62. }];
  63. [self.myBackgroundView addSubview:self.sourceLab];
  64. [self.sourceLab mas_makeConstraints:^(MASConstraintMaker *make) {
  65. make.left.equalTo(self.articlaImage.mas_right).offset(10);
  66. make.top.equalTo(self.articleContentLab.mas_bottom).offset(5);
  67. }];
  68. [self.myBackgroundView addSubview:self.closeButton];
  69. [self.closeButton mas_makeConstraints:^(MASConstraintMaker *make) {
  70. make.right.equalTo(self.myBackgroundView).offset(-10);
  71. make.top.equalTo(self.myBackgroundView).offset(10);
  72. make.width.height.mas_equalTo(10);
  73. }];
  74. }
  75. return self;
  76. }
  77. - (UIImageView *)articlaImage{
  78. if (!_articlaImage) {
  79. _articlaImage = [UIImageView new];
  80. }
  81. return _articlaImage;
  82. }
  83. - (UILabel *)articleNamelab{
  84. if (!_articleNamelab) {
  85. _articleNamelab = [UILabel new];
  86. _articleNamelab.textColor = UIColorHex(333333);
  87. _articleNamelab.font = [UIFont systemFontOfSize:15.f weight:UIFontWeightLight];
  88. }
  89. return _articleNamelab;
  90. }
  91. - (UILabel *)articleContentLab{
  92. if (!_articleContentLab) {
  93. _articleContentLab = [UILabel new];
  94. _articleContentLab.textColor = UIColorHex(999999);
  95. _articleContentLab.font = [UIFont systemFontOfSize:12.f weight:UIFontWeightLight];
  96. _articleContentLab.numberOfLines = 0;
  97. }
  98. return _articleContentLab;
  99. }
  100. - (UILabel *)sourceLab{
  101. if (!_sourceLab) {
  102. _sourceLab = [UILabel new];
  103. _sourceLab.textColor = UIColorHex(999999);
  104. _sourceLab.font = [UIFont systemFontOfSize:12.f weight:UIFontWeightLight];
  105. _sourceLab.textAlignment = NSTextAlignmentLeft;
  106. _sourceLab.numberOfLines = 0;
  107. }
  108. return _sourceLab;
  109. }
  110. - (TDButton *)closeButton{
  111. if (!_closeButton) {
  112. _closeButton = [[TDButton alloc]init];
  113. [_closeButton setImage:IMG(@"叉号") forState:UIControlStateNormal];
  114. [_closeButton setCurrentButtonHotSize:CGSizeZero];
  115. }
  116. return _closeButton;
  117. }
  118. - (UIView *)myBackgroundView{
  119. if (!_myBackgroundView){
  120. _myBackgroundView = [UIView new];
  121. _myBackgroundView.backgroundColor = UIColorHex(F4F5F5);
  122. }
  123. return _myBackgroundView;
  124. }
  125. @end