Нет описания

FKCirDetailImgDescCell.m 2.8KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. //
  2. // FKCirDetailImgDescCell.m
  3. // FirstLink
  4. //
  5. // Created by jack on 16/6/16.
  6. // Copyright © 2016年 FirstLink. All rights reserved.
  7. //
  8. #import "FKCirDetailImgDescCell.h"
  9. #import "FKCircleDetailViewModel.h"
  10. @interface FKCirDetailImgDescCell ()
  11. @property (nonatomic, strong) UILabel *titleLabel;
  12. @end
  13. @implementation FKCirDetailImgDescCell
  14. - (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
  15. if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
  16. [self addAllSubviews];
  17. self.selectionStyle = UITableViewCellSelectionStyleNone;
  18. self.contentView.backgroundColor = [UIColor whiteColor];
  19. }
  20. return self;
  21. }
  22. - (void)addAllSubviews{
  23. [self.contentView addSubview:self.proImgView];
  24. [self.contentView addSubview:self.titleLabel];
  25. [self.proImgView mas_makeConstraints:^(MASConstraintMaker *make) {
  26. make.top.left.right.equalTo(self.contentView);
  27. make.height.mas_equalTo(UISCREENWIDTH);
  28. }];
  29. [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  30. make.top.equalTo(self.proImgView.mas_bottom).offset(15);
  31. make.left.equalTo(self.contentView).offset(15);
  32. make.right.equalTo(self.contentView).offset(- 15);
  33. }];
  34. }
  35. + (CGFloat)cellHeightForTitle:(NSString *)title{
  36. if (!title.length) return UISCREENWIDTH;
  37. CGFloat descH = [FLStringHelper sizeOfAttributeString:title
  38. lineSpace:2.5
  39. width:UISCREENWIDTH - 30
  40. font:[UIFont systemFontOfSize:14]
  41. maxRow:NSIntegerMax].height;
  42. return descH + 30 + UISCREENWIDTH;
  43. }
  44. - (void)fk_configWithViewModel:(id)viewModel indexPath:(NSIndexPath *)indexPath{
  45. if ([viewModel isKindOfClass:[FKCircleDetailViewModel class]]) {
  46. FKCircleDetailViewModel *cirViewModel = (FKCircleDetailViewModel *)viewModel;
  47. FKCirDetailContentItem *contentItem = [cirViewModel.dataItem contentDetailItemForIndex:indexPath.row];
  48. [self.proImgView setImageWithURL:contentItem.contentData.picUrl cdnWidth:UISCREENWIDTH];
  49. self.titleLabel.text = contentItem.contentData.contentText;
  50. }
  51. }
  52. #pragma mark - property
  53. - (UIImageView *)proImgView{
  54. if (_proImgView == nil) {
  55. _proImgView = [[UIImageView alloc]init];
  56. _proImgView.contentMode = UIViewContentModeScaleAspectFit;
  57. }
  58. return _proImgView;
  59. }
  60. - (UILabel *)titleLabel{
  61. if (_titleLabel == nil) {
  62. _titleLabel = [[UILabel alloc]init];
  63. _titleLabel.font = [UIFont systemFontOfSize:14];
  64. _titleLabel.textColor = UIColorFromRGB(0x333333);
  65. _titleLabel.numberOfLines = 0;
  66. }
  67. return _titleLabel;
  68. }
  69. @end