説明なし

FKProductRecommendCell.m 4.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. //
  2. // FKProductRecommendCell.m
  3. // FirstLink
  4. //
  5. // Created by jack on 16/1/14.
  6. // Copyright © 2016年 FirstLink. All rights reserved.
  7. //
  8. #import "FKProductRecommendCell.h"
  9. #import "FKProDetailViewModel.h"
  10. @interface FKProductRecommendCell ()
  11. @property (nonatomic, strong) UIImageView *headerImgView;
  12. @property (nonatomic, strong) UILabel *nameLabel;
  13. @property (nonatomic, strong) UILabel *titleLabel;
  14. @property (nonatomic, strong) UIView *bottomLine;
  15. @end
  16. @implementation FKProductRecommendCell
  17. - (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
  18. if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
  19. [self addAllSubviews];
  20. self.contentView.backgroundColor = [UIColor whiteColor];
  21. self.selectionStyle = UITableViewCellSelectionStyleNone;
  22. }
  23. return self;
  24. }
  25. - (void)addAllSubviews{
  26. [self.contentView addSubview:self.headerImgView];
  27. [self.contentView addSubview:self.nameLabel];
  28. [self.contentView addSubview:self.titleLabel];
  29. [self.contentView addSubview:self.bottomLine];
  30. [self.headerImgView mas_makeConstraints:^(MASConstraintMaker *make) {
  31. make.top.equalTo(self.contentView).offset(10);
  32. make.left.equalTo(self.contentView).offset(15);
  33. make.size.mas_equalTo(CGSizeMake(50, 50));
  34. }];
  35. [self.nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  36. make.left.equalTo(self.headerImgView.mas_right).offset(11);
  37. make.centerY.equalTo(self.headerImgView);
  38. }];
  39. [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  40. make.top.equalTo(self.headerImgView.mas_bottom).offset(13);
  41. make.left.equalTo(self.contentView).offset(15);
  42. make.right.equalTo(self.contentView).offset(- 15);
  43. }];
  44. [self.bottomLine mas_makeConstraints:^(MASConstraintMaker *make) {
  45. make.left.right.bottom.equalTo(self.contentView);
  46. make.height.mas_equalTo(0.5);
  47. }];
  48. }
  49. + (CGFloat)cellHeightForTitleText:(NSString *)text{
  50. CGFloat textHeight = [FLStringHelper sizeOfAttributeString:text lineSpace:2.4
  51. width:UISCREENWIDTH - 30
  52. font:([UIFont systemFontOfSize:14])
  53. maxRow:NSIntegerMax].height;
  54. return textHeight + 28 + 50 + 10;
  55. }
  56. //- (void)fk_configWithViewModel:(FKProductDetailViewModel *)viewModel indexPath:(NSIndexPath *)indexPath{
  57. // if ([viewModel isKindOfClass:[FKProductDetailViewModel class]]) {
  58. //
  59. // self.nameLabel.text = [NSString stringWithFormat:@"%@ 推荐", viewModel.dataItem.recommendInfo.nickName];
  60. // self.titleLabel.attributedText = [FLStringHelper attStringWithText:viewModel.dataItem.recommendInfo.recommendTitle lineSpace:2.4];
  61. // [self.headerImgView sd_setImageWithURL:[NSURL URLWithString:viewModel.dataItem.recommendInfo.headerPicUrl]];
  62. // }
  63. //}
  64. - (void)fk_configWithViewModel:(id)viewModel indexPath:(NSIndexPath *)indexPath{
  65. if ([viewModel isKindOfClass:[FKProDetailViewModel class]]) {
  66. FKProDetailViewModel *detailModel = (FKProDetailViewModel *)viewModel;
  67. self.nameLabel.text = [NSString stringWithFormat:@"%@ 推荐", detailModel.dataItem.recommendInfo.nickName];
  68. self.titleLabel.attributedText = [FLStringHelper attStringWithText:detailModel.dataItem.recommendInfo.recommendTitle lineSpace:2.4];
  69. [self.headerImgView sd_setImageWithURL:[NSURL URLWithString:detailModel.dataItem.recommendInfo.headerPicUrl]];
  70. }
  71. }
  72. #pragma mark - property
  73. - (UIImageView *)headerImgView{
  74. if (_headerImgView == nil) {
  75. _headerImgView = [[UIImageView alloc]init];
  76. _headerImgView.layer.cornerRadius = 25;
  77. _headerImgView.layer.masksToBounds = YES;
  78. }
  79. return _headerImgView;
  80. }
  81. - (UILabel *)nameLabel{
  82. if (_nameLabel == nil) {
  83. _nameLabel = [[UILabel alloc]init];
  84. _nameLabel.textColor = UIColorFromRGB(0x9B9B9B);
  85. _nameLabel.font = [UIFont systemFontOfSize:13];
  86. }
  87. return _nameLabel;
  88. }
  89. - (UILabel *)titleLabel{
  90. if (_titleLabel == nil) {
  91. _titleLabel = [[UILabel alloc]init];
  92. _titleLabel.textColor = UIColorFromRGB(0x666666);
  93. _titleLabel.font = [UIFont systemFontOfSize:14];
  94. _titleLabel.numberOfLines = 0;
  95. _titleLabel.lineBreakMode = NSLineBreakByWordWrapping;
  96. }
  97. return _titleLabel;
  98. }
  99. - (UIView *)bottomLine{
  100. if (_bottomLine == nil) {
  101. _bottomLine = [[UIView alloc]init];
  102. _bottomLine.backgroundColor = UIColorFromRGB(0xe5e5e5);
  103. }
  104. return _bottomLine;
  105. }
  106. @end