《省钱达人》与《猎豆优选》UI相同版。域名tbk

DRTimeLineRecomCell.m 6.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218
  1. //
  2. // DRTimeLineRecomCell.m
  3. // YouHuiProject
  4. //
  5. // Created by 小花 on 2019/1/7.
  6. // Copyright © 2019年 kuxuan. All rights reserved.
  7. //
  8. #import "DRTimeLineRecomCell.h"
  9. #import "CCCopyLabel.h"
  10. #import "DRTimeLineCommentView.h"
  11. #import "DRRecomPhotoView.h"
  12. @interface DRTimeLineRecomCell ()
  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) DRTimeLineCommentView *commentView;
  20. @property (nonatomic, strong) DRRecomPhotoView *PhotoContainerView;
  21. @end
  22. @implementation DRTimeLineRecomCell
  23. + (instancetype)cellWithTableView:(UITableView *)tableView {
  24. static NSString *cellID = nil;
  25. cellID = NSStringFromClass([self class]);
  26. DRTimeLineRecomCell *cell = [tableView dequeueReusableCellWithIdentifier:cellID];
  27. if (!cell) {
  28. cell = [[DRTimeLineRecomCell 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.title);
  76. make.top.mas_equalTo(self.PhotoContainerView.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:(DRTimeLineModel *)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. bottomView = _timeLabel;
  105. // [self.commentView setupWithLikeItemsArray:model.shareUser contentText:model.show_comment];
  106. // if (!model.shareUser.count && model.show_comment.length==0) {
  107. // bottomView = _timeLabel;
  108. // } else {
  109. // bottomView = _commentView;
  110. // }
  111. [self setupAutoHeightWithBottomView:bottomView bottomMargin:15];
  112. }
  113. - (UIImageView *)iconView {
  114. if (!_iconView) {
  115. _iconView = [[UIImageView alloc] init];
  116. _iconView.layer.cornerRadius = 21;
  117. _iconView.layer.masksToBounds = YES;
  118. _iconView.backgroundColor = [UIColor yhGrayColor];
  119. }
  120. return _iconView;
  121. }
  122. - (UILabel *)name {
  123. if (!_name) {
  124. _name = [[UILabel alloc] init];
  125. _name.font = [UIFont boldSystemFontOfSize:17];
  126. _name.textColor = [UIColor YHColorWithHex:0x576B95];
  127. }
  128. return _name;
  129. }
  130. - (UILabel *)title {
  131. if (!_title) {
  132. _title = [[CCCopyLabel alloc] init];
  133. _title.font = [UIFont fontWithName:@"HelveticaNeue" size:17];
  134. _title.textColor = [UIColor YHColorWithHex:0x222222];
  135. _title.numberOfLines = 0;
  136. }
  137. return _title;
  138. }
  139. //- (UILabel *)localLabel {
  140. // if (!_localLabel) {
  141. // _localLabel = [[UILabel alloc] init];
  142. // _localLabel.font = [UIFont systemFontOfSize:14];
  143. // _localLabel.textColor = [UIColor YHColorWithHex:0x576B95];
  144. // }
  145. // return _localLabel;
  146. //}
  147. - (UILabel *)timeLabel {
  148. if (!_timeLabel) {
  149. _timeLabel = [[UILabel alloc] init];
  150. _timeLabel.font = [UIFont systemFontOfSize:14];
  151. _timeLabel.textColor = [UIColor YHColorWithHex:0xB2B2B2];
  152. }
  153. return _timeLabel;
  154. }
  155. - (UIButton *)shareButton {
  156. if (!_shareButton) {
  157. _shareButton = [UIButton buttonWithType:UIButtonTypeCustom];
  158. [_shareButton setTitle:@"分享" forState:UIControlStateNormal];
  159. _shareButton.layer.cornerRadius = 10;
  160. _shareButton.layer.borderColor = [UIColor YHColorWithHex:0x576B95].CGColor;
  161. _shareButton.layer.borderWidth = 1;
  162. [_shareButton setTitleColor:[UIColor YHColorWithHex:0x576B95] forState:UIControlStateNormal];
  163. _shareButton.titleLabel.font = [UIFont systemFontOfSize:11];
  164. [_shareButton addTarget:self action:@selector(shareClick) forControlEvents:UIControlEventTouchUpInside];
  165. }
  166. return _shareButton;
  167. }
  168. //- (DRTimeLineCommentView *)commentView {
  169. // if (!_commentView) {
  170. // _commentView = [DRTimeLineCommentView new];
  171. // }
  172. // return _commentView;
  173. //}
  174. - (DRRecomPhotoView *)PhotoContainerView {
  175. if (!_PhotoContainerView) {
  176. _PhotoContainerView = [[DRRecomPhotoView alloc] initWithFrame:CGRectMake(0, 0, 104, 104)];
  177. }
  178. return _PhotoContainerView;
  179. }
  180. @end