暫無描述

FKCircleHeaderCell.m 5.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. //
  2. // FKCircleHeaderCell.m
  3. // FirstLink
  4. //
  5. // Created by jack on 16/6/12.
  6. // Copyright © 2016年 FirstLink. All rights reserved.
  7. //
  8. #import "FKCircleHeaderCell.h"
  9. #import "FKCircleBestViewModel.h"
  10. @interface FKCircleHeaderCell ()
  11. @property (nonatomic, strong) UIImageView *headerImgView;
  12. @property (nonatomic, strong) UIView *vertLine;
  13. @property (nonatomic, strong) UIView *containerView;
  14. @property (nonatomic, strong) UIView *cornerCoverView;
  15. @property (nonatomic, strong) UILabel *nameLabel;
  16. @property (nonatomic, strong) UILabel *typeLabel;
  17. @property (nonatomic, strong) UILabel *timeLabel;
  18. @end
  19. @implementation FKCircleHeaderCell
  20. - (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
  21. if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
  22. [self addAllSubviews];
  23. self.selectionStyle = UITableViewCellSelectionStyleNone;
  24. self.backgroundColor = [UIColor clearColor];
  25. }
  26. return self;
  27. }
  28. - (void)addAllSubviews{
  29. [self.contentView addSubview:self.containerView];
  30. [self.contentView addSubview:self.cornerCoverView];
  31. [self.containerView addSubview:self.headerImgView];
  32. [self.containerView addSubview:self.vertLine];
  33. [self.containerView addSubview:self.nameLabel];
  34. [self.containerView addSubview:self.typeLabel];
  35. [self.containerView addSubview:self.timeLabel];
  36. [self.containerView mas_makeConstraints:^(MASConstraintMaker *make) {
  37. make.edges.insets(UIEdgeInsetsMake(0, 5, 0, 5));
  38. }];
  39. [self.cornerCoverView mas_makeConstraints:^(MASConstraintMaker *make) {
  40. make.left.right.bottom.equalTo(self.containerView);
  41. make.height.mas_equalTo(8);
  42. }];
  43. [self.headerImgView mas_makeConstraints:^(MASConstraintMaker *make) {
  44. make.left.equalTo(self.containerView).offset(6);
  45. make.centerY.equalTo(self.containerView);
  46. make.size.mas_equalTo(CGSizeMake(40, 40));
  47. }];
  48. [self.nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  49. make.left.equalTo(self.headerImgView.mas_right).offset(10);
  50. make.bottom.equalTo(self.containerView.mas_centerY).offset(- 4);
  51. }];
  52. [self.vertLine mas_makeConstraints:^(MASConstraintMaker *make) {
  53. make.left.equalTo(self.headerImgView.mas_right).offset(10);
  54. make.top.equalTo(self.containerView.mas_centerY).offset(4);
  55. make.size.mas_equalTo(CGSizeMake(3, 12));
  56. }];
  57. [self.typeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  58. make.left.equalTo(self.vertLine.mas_right).offset(5);
  59. make.centerY.equalTo(self.vertLine);
  60. }];
  61. [self.timeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  62. make.top.equalTo(self.containerView).offset(10);
  63. make.right.equalTo(self.containerView).offset(- 10);
  64. }];
  65. }
  66. - (void)fk_configWithViewModel:(id)viewModel indexPath:(NSIndexPath *)indexPath{
  67. if ([viewModel isKindOfClass:[FKCircleBestViewModel class]]) {
  68. FKCircleBestViewModel *bestViewModel = (FKCircleBestViewModel *)viewModel;
  69. FKCircleContentItem *contentItem = [bestViewModel circleContentItemForIndexPath:indexPath];
  70. [self.headerImgView setImageWithURL:contentItem.userItem.picUrl cdnWidth:40];
  71. self.nameLabel.text = contentItem.userItem.nickName;
  72. if ([contentItem getCircleType] == kCircleTypeUserShare) {
  73. self.typeLabel.text = @"晒单推荐";
  74. self.vertLine.backgroundColor = UIColorFromRGB(0xf5a623);
  75. }else if ([contentItem getCircleType] == kCircleTypeInfoShare){
  76. self.typeLabel.text = @"种草资讯";
  77. self.vertLine.backgroundColor = UIColorFromRGB(0xff6362);
  78. }
  79. self.timeLabel.text = contentItem.realCreateTime;
  80. }
  81. }
  82. #pragma mark - property
  83. - (UIView *)containerView{
  84. if (_containerView == nil) {
  85. _containerView = [[UIView alloc]init];
  86. _containerView.backgroundColor = [UIColor whiteColor];
  87. _containerView.layer.cornerRadius = 4.0f;
  88. }
  89. return _containerView;
  90. }
  91. - (UIView *)cornerCoverView{
  92. if (_cornerCoverView == nil) {
  93. _cornerCoverView = [[UIView alloc]init];
  94. _cornerCoverView.backgroundColor = [UIColor whiteColor];
  95. }
  96. return _cornerCoverView;
  97. }
  98. - (UIImageView *)headerImgView{
  99. if (_headerImgView == nil) {
  100. _headerImgView = [[UIImageView alloc]init];
  101. _headerImgView.layer.cornerRadius = 20;
  102. _headerImgView.layer.masksToBounds = YES;
  103. }
  104. return _headerImgView;
  105. }
  106. - (UILabel *)nameLabel{
  107. if (_nameLabel == nil) {
  108. _nameLabel = [[UILabel alloc]init];
  109. _nameLabel.textColor = UIColorFromRGB(0x262626);
  110. _nameLabel.font = [UIFont systemFontOfSize:14];
  111. }
  112. return _nameLabel;
  113. }
  114. - (UILabel *)typeLabel{
  115. if (_typeLabel == nil) {
  116. _typeLabel = [[UILabel alloc]init];
  117. _typeLabel.textColor = UIColorFromRGB(0x262626);
  118. _typeLabel.font = [UIFont systemFontOfSize:12];
  119. _typeLabel.numberOfLines = 1;
  120. }
  121. return _typeLabel;
  122. }
  123. - (UILabel *)timeLabel{
  124. if (_timeLabel == nil) {
  125. _timeLabel = [[UILabel alloc]init];
  126. _timeLabel.textColor = UIColorFromRGB(0xcccccc);
  127. _timeLabel.font = [UIFont systemFontOfSize:13];
  128. }
  129. return _timeLabel;
  130. }
  131. - (UIView *)vertLine{
  132. if (_vertLine == nil) {
  133. _vertLine = [[UIView alloc]init];
  134. _vertLine.backgroundColor = [UIColor redColor];
  135. }
  136. return _vertLine;
  137. }
  138. @end