猎豆优选

LDTimeLineRecomCell.m 6.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217
  1. //
  2. // LDTimeLineRecomCell.m
  3. // YouHuiProject
  4. //
  5. // Created by 小花 on 2019/1/7.
  6. // Copyright © 2019年 kuxuan. All rights reserved.
  7. //
  8. #import "LDTimeLineRecomCell.h"
  9. #import "CCCopyLabel.h"
  10. #import "LDTimeLineCommentView.h"
  11. #import "LDRecomPhotoView.h"
  12. @interface LDTimeLineRecomCell ()
  13. @property (nonatomic, strong) UIImageView *iconView;
  14. @property (nonatomic, strong) UILabel *name;
  15. @property (nonatomic, strong) CCCopyLabel *title;
  16. @property (nonatomic, strong) UILabel *localLabel;
  17. @property (nonatomic, strong) UILabel *timeLabel;
  18. @property (nonatomic, strong) UIButton *shareButton;
  19. @property (nonatomic, strong) LDTimeLineCommentView *commentView;
  20. @property (nonatomic, strong) LDRecomPhotoView *PhotoContainerView;
  21. @end
  22. @implementation LDTimeLineRecomCell
  23. + (instancetype)cellWithTableView:(UITableView *)tableView {
  24. static NSString *cellID = nil;
  25. cellID = NSStringFromClass([self class]);
  26. LDTimeLineRecomCell *cell = [tableView dequeueReusableCellWithIdentifier:cellID];
  27. if (!cell) {
  28. cell = [[LDTimeLineRecomCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellID];
  29. cell.selectionStyle = UITableViewCellSelectionStyleNone;
  30. }
  31. return cell;
  32. }
  33. - (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
  34. self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
  35. if (self) {
  36. [self initSubViews];
  37. }
  38. return self;
  39. }
  40. - (void)initSubViews {
  41. [self.contentView addSubview:self.iconView];
  42. [self.contentView addSubview:self.name];
  43. [self.contentView addSubview:self.title];
  44. [self.contentView addSubview:self.PhotoContainerView];
  45. [self.contentView addSubview:self.localLabel];
  46. [self.contentView addSubview:self.timeLabel];
  47. [self.contentView addSubview:self.shareButton];
  48. [self.contentView addSubview:self.commentView];
  49. [self.iconView mas_makeConstraints:^(MASConstraintMaker *make) {
  50. make.left.mas_equalTo(10);
  51. make.top.mas_equalTo(14);
  52. make.width.height.mas_equalTo(42);
  53. }];
  54. [self.name mas_makeConstraints:^(MASConstraintMaker *make) {
  55. make.left.mas_equalTo(self.iconView.mas_right).mas_offset(10);
  56. make.top.mas_equalTo(17);
  57. make.right.mas_equalTo(-10);
  58. }];
  59. [self.title mas_makeConstraints:^(MASConstraintMaker *make) {
  60. make.top.mas_equalTo(self.name.mas_bottom).mas_offset(7);
  61. make.left.mas_equalTo(self.name);
  62. make.right.mas_equalTo(-10);
  63. }];
  64. [self.PhotoContainerView mas_makeConstraints:^(MASConstraintMaker *make) {
  65. make.left.mas_equalTo(self.title.mas_left);
  66. make.top.mas_equalTo(self.title.mas_bottom).mas_offset(8);
  67. make.width.height.mas_equalTo(144);
  68. }];
  69. [self.localLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  70. make.left.mas_equalTo(self.title.mas_left);
  71. make.right.mas_equalTo(-10);
  72. make.top.mas_equalTo(self.PhotoContainerView.mas_bottom).mas_offset(8);
  73. }];
  74. [self.timeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  75. make.left.mas_equalTo(self.localLabel);
  76. make.top.mas_equalTo(self.localLabel.mas_bottom).mas_offset(8);
  77. make.right.mas_equalTo(-10);
  78. }];
  79. [self.shareButton mas_makeConstraints:^(MASConstraintMaker *make) {
  80. make.right.mas_equalTo(-10);
  81. make.centerY.mas_equalTo(self.timeLabel.mas_centerY);
  82. make.width.mas_equalTo(50);
  83. make.height.mas_equalTo(20);
  84. }];
  85. _commentView.sd_layout
  86. .leftEqualToView(self.name)
  87. .rightSpaceToView(self.contentView, 10)
  88. .topSpaceToView(_timeLabel, 10);
  89. }
  90. - (void)shareClick {
  91. if (self.shareClickBlock) {
  92. self.shareClickBlock();
  93. }
  94. }
  95. - (void)setModel:(LDTimeLineModel *)model {
  96. _model = model;
  97. [self.iconView sd_setFadeImageWithURL:[NSURL URLWithString:model.subscribe_img] placeholderImage:nil options:0 progress:nil completed:nil];
  98. self.name.text = model.subscribe_title;
  99. self.title.text = model.show_content;
  100. [self.PhotoContainerView setPicPathStringsArray:@[model.img]];
  101. self.timeLabel.text = model.pass_time;
  102. self.localLabel.text = model.location;
  103. UIView *bottomView;
  104. [self.commentView setupWithLikeItemsArray:model.shareUser contentText:model.show_comment];
  105. if (!model.shareUser.count && model.show_comment.length==0) {
  106. bottomView = _timeLabel;
  107. } else {
  108. bottomView = _commentView;
  109. }
  110. [self setupAutoHeightWithBottomView:bottomView bottomMargin:15];
  111. }
  112. - (UIImageView *)iconView {
  113. if (!_iconView) {
  114. _iconView = [[UIImageView alloc] init];
  115. _iconView.layer.cornerRadius = 21;
  116. _iconView.layer.masksToBounds = YES;
  117. _iconView.backgroundColor = [UIColor yhGrayColor];
  118. }
  119. return _iconView;
  120. }
  121. - (UILabel *)name {
  122. if (!_name) {
  123. _name = [[UILabel alloc] init];
  124. _name.font = [UIFont boldSystemFontOfSize:17];
  125. _name.textColor = [UIColor YHColorWithHex:0x576B95];
  126. }
  127. return _name;
  128. }
  129. - (UILabel *)title {
  130. if (!_title) {
  131. _title = [[CCCopyLabel alloc] init];
  132. _title.font = [UIFont fontWithName:@"HelveticaNeue" size:17];
  133. _title.textColor = [UIColor YHColorWithHex:0x222222];
  134. _title.numberOfLines = 0;
  135. }
  136. return _title;
  137. }
  138. - (UILabel *)localLabel {
  139. if (!_localLabel) {
  140. _localLabel = [[UILabel alloc] init];
  141. _localLabel.font = [UIFont systemFontOfSize:14];
  142. _localLabel.textColor = [UIColor YHColorWithHex:0x576B95];
  143. }
  144. return _localLabel;
  145. }
  146. - (UILabel *)timeLabel {
  147. if (!_timeLabel) {
  148. _timeLabel = [[UILabel alloc] init];
  149. _timeLabel.font = [UIFont systemFontOfSize:14];
  150. _timeLabel.textColor = [UIColor YHColorWithHex:0xB2B2B2];
  151. }
  152. return _timeLabel;
  153. }
  154. - (UIButton *)shareButton {
  155. if (!_shareButton) {
  156. _shareButton = [UIButton buttonWithType:UIButtonTypeCustom];
  157. [_shareButton setTitle:@"分享" forState:UIControlStateNormal];
  158. _shareButton.layer.cornerRadius = 10;
  159. _shareButton.layer.borderColor = [UIColor YHColorWithHex:0x576B95].CGColor;
  160. _shareButton.layer.borderWidth = 1;
  161. [_shareButton setTitleColor:[UIColor YHColorWithHex:0x576B95] forState:UIControlStateNormal];
  162. _shareButton.titleLabel.font = [UIFont systemFontOfSize:11];
  163. [_shareButton addTarget:self action:@selector(shareClick) forControlEvents:UIControlEventTouchUpInside];
  164. }
  165. return _shareButton;
  166. }
  167. - (LDTimeLineCommentView *)commentView {
  168. if (!_commentView) {
  169. _commentView = [LDTimeLineCommentView new];
  170. }
  171. return _commentView;
  172. }
  173. - (LDRecomPhotoView *)PhotoContainerView {
  174. if (!_PhotoContainerView) {
  175. _PhotoContainerView = [[LDRecomPhotoView alloc] initWithFrame:CGRectMake(0, 0, 104, 104)];
  176. }
  177. return _PhotoContainerView;
  178. }
  179. @end