Geen omschrijving

FKCircleProImgCell.m 3.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. //
  2. // FKCircleProImgCell.m
  3. // FirstLink
  4. //
  5. // Created by jack on 16/6/12.
  6. // Copyright © 2016年 FirstLink. All rights reserved.
  7. //
  8. #import "FKCircleProImgCell.h"
  9. #import "FKCircleBestViewModel.h"
  10. #import "FKMyCircleViewModel.h"
  11. @interface FKCircleProImgCell ()
  12. @property (nonatomic, strong) UIView *containerView;
  13. @property (nonatomic, strong) UIImageView *tagImgView;
  14. @end
  15. @implementation FKCircleProImgCell
  16. - (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
  17. if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
  18. [self addAllSubviews];
  19. self.selectionStyle = UITableViewCellSelectionStyleNone;
  20. self.backgroundColor = [UIColor clearColor];
  21. }
  22. return self;
  23. }
  24. - (void)addAllSubviews{
  25. [self.contentView addSubview:self.containerView];
  26. [self.containerView addSubview:self.proImgView];
  27. [self.containerView addSubview:self.tagImgView];
  28. [self.containerView mas_makeConstraints:^(MASConstraintMaker *make) {
  29. make.edges.insets(UIEdgeInsetsMake(0, 5, 0, 5));
  30. }];
  31. [self.proImgView mas_makeConstraints:^(MASConstraintMaker *make) {
  32. make.edges.insets(UIEdgeInsetsZero);
  33. }];
  34. [self.tagImgView mas_makeConstraints:^(MASConstraintMaker *make) {
  35. make.top.equalTo(self.proImgView).offset(12);
  36. make.left.equalTo(self.proImgView).offset(15);
  37. }];
  38. }
  39. - (void)fk_configWithViewModel:(id)viewModel indexPath:(NSIndexPath *)indexPath{
  40. if ([viewModel isKindOfClass:[FKCircleBestViewModel class]]) {
  41. FKCircleBestViewModel *bestViewModel = (FKCircleBestViewModel *)viewModel;
  42. FKCircleContentItem *contentItem = [bestViewModel circleContentItemForIndexPath:indexPath];
  43. [self.proImgView setImageWithURL:contentItem.shareItem.firstPicUrl cdnWidth:UISCREENWIDTH - 10];
  44. NSInteger recLevel = contentItem.shareItem.recommendLevel.integerValue;
  45. self.tagImgView.hidden = (recLevel == 2 ? NO : YES);
  46. }
  47. if ([viewModel isKindOfClass:[FKMyCircleViewModel class]]) {
  48. FKMyCircleViewModel *myCircleModel = (FKMyCircleViewModel *)viewModel;
  49. FKMyCircleContentItem *contentItem = [myCircleModel circleContentItemAtIndex:indexPath.section - 1];
  50. [self.proImgView setImageWithURL:contentItem.shareItem.firstPicUrl cdnWidth:UISCREENWIDTH - 10];
  51. NSInteger recLevel = contentItem.shareItem.recommendLevel.integerValue;
  52. self.tagImgView.hidden = (recLevel == 2 ? NO : YES);
  53. }
  54. }
  55. + (CGFloat)imageHeight{
  56. return UISCREENWIDTH - 10;
  57. }
  58. + (CGFloat)cellHeight{
  59. return [self imageHeight];
  60. }
  61. + (CGSize)imageSize{
  62. return CGSizeMake(UISCREENWIDTH - 10, UISCREENWIDTH - 10);
  63. }
  64. - (UIImageView *)proImgView{
  65. if (_proImgView == nil) {
  66. _proImgView = [[UIImageView alloc]init];
  67. _proImgView.contentMode = UIViewContentModeScaleAspectFit;
  68. }
  69. return _proImgView;
  70. }
  71. - (UIView *)containerView{
  72. if (_containerView == nil) {
  73. _containerView = [[UIView alloc]init];
  74. _containerView.backgroundColor = [UIColor whiteColor];
  75. }
  76. return _containerView;
  77. }
  78. - (UIImageView *)tagImgView{
  79. if (_tagImgView == nil) {
  80. _tagImgView = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"bestCircle_icon"]];
  81. }
  82. return _tagImgView;
  83. }
  84. @end