HomeCollectionViewCell.m 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. //
  2. // HomeCollectionViewCell.m
  3. // jitao
  4. //
  5. // Created by 罗云飞 on 2017/12/20.
  6. // Copyright © 2017年 罗云飞. All rights reserved.
  7. //
  8. #import "HomeCollectionViewCell.h"
  9. @implementation HomeCollectionViewCell{
  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:(BusinessModel *)model{
  39. //项目默认
  40. if (model.minLogoUrl == NULL) {
  41. [incoImage setImage:NewImageNamed(@"项目默认")];
  42. }else{
  43. [incoImage sd_setImageWithURL:NewURL([model.minLogoUrl mosaicUrlPrefix]) placeholderImage:NewImageNamed(@"cppt")];
  44. }
  45. name.text = model.name;
  46. }
  47. @end