AssetsCollectionViewCell.m 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. //
  2. // AssetsCollectionViewCell.m
  3. // jitao
  4. //
  5. // Created by 罗云飞 on 2018/2/6.
  6. // Copyright © 2018年 罗云飞. All rights reserved.
  7. //
  8. #import "AssetsCollectionViewCell.h"
  9. @implementation AssetsCollectionViewCell{
  10. UIImageView *incoImage;
  11. UILabel *name;//名称
  12. }
  13. - (id)initWithFrame:(CGRect)frame
  14. {
  15. self = [super initWithFrame:frame];
  16. if (self) {
  17. incoImage = [UIImageView new];
  18. [self.contentView addSubview:incoImage];
  19. CGFloat proportion = (CGFloat)210/335;//图片宽高比
  20. incoImage.sd_layout
  21. .leftSpaceToView(self.contentView, 0)
  22. .rightSpaceToView(self.contentView, 0)
  23. .topSpaceToView(self.contentView, 0)
  24. .autoHeightRatio(proportion);
  25. name = [UILabel new];
  26. name.font = NewFont(fitScreenWidth(13));
  27. name.textColor = NewBlackColor;
  28. name.textAlignment = NSTextAlignmentCenter;
  29. [self.contentView addSubview:name];
  30. name.sd_layout
  31. .leftEqualToView(incoImage)
  32. .heightIs(15)
  33. .topSpaceToView(incoImage, 5)
  34. .widthIs(SCREEN_WIDTH/2-15-5);
  35. }
  36. return self;
  37. }
  38. - (void)assignment:(KnowledgeproductionModel *)model{
  39. //项目默认
  40. if (model.img == NULL) {
  41. [incoImage setImage:NewImageNamed(@"项目默认")];
  42. }else{
  43. [incoImage sd_setImageWithURL:NewURL([model.img mosaicUrlPrefix]) placeholderImage:NewImageNamed(@"cppt")];
  44. }
  45. name.text = model.name;
  46. }
  47. @end