ServiceRecommendCell.m 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. //
  2. // ServiceRecommendCell.m
  3. // jitao
  4. //
  5. // Created by 罗云飞 on 2017/12/21.
  6. // Copyright © 2017年 罗云飞. All rights reserved.
  7. //
  8. #import "ServiceRecommendCell.h"
  9. @implementation ServiceRecommendCell
  10. - (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
  11. self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
  12. if (self) {
  13. UILabel *line = [UILabel new];
  14. line.backgroundColor = NewLineGrayColor;
  15. [self.contentView addSubview:line];
  16. line.sd_layout
  17. .leftEqualToView(self.contentView)
  18. .heightIs(10)
  19. .rightEqualToView(self.contentView)
  20. .topEqualToView(self.contentView);
  21. CGFloat proportion = (CGFloat)210/335;//图片宽高比
  22. _image = [UIImageView new];
  23. _image.backgroundColor = NewClearColor;
  24. ViewRadius(_image, 5);
  25. [self.contentView addSubview:_image];
  26. _image.sd_layout
  27. .leftSpaceToView(self.contentView, 15)
  28. .topSpaceToView(line, 15)
  29. .widthIs(SCREEN_WIDTH/2-20)
  30. .autoHeightRatio(proportion);
  31. _title = [UILabel new];
  32. _title.numberOfLines = 1;
  33. _title.lineBreakMode = NSLineBreakByTruncatingTail;
  34. _title.font = NewFont(fitScreenWidth(14));
  35. [self.contentView addSubview:_title];
  36. _title.sd_layout
  37. .leftSpaceToView(_image, 10)
  38. .heightIs(16)
  39. .topEqualToView(_image)
  40. .rightSpaceToView(self.contentView, 15);
  41. UILabel *line1 = [UILabel new];
  42. line1.backgroundColor = NewLineGrayColor;
  43. [self.contentView addSubview:line1];
  44. line1.sd_layout
  45. .leftEqualToView(_title)
  46. .topSpaceToView(line, 44)
  47. .heightIs(0.8)
  48. .rightEqualToView(self.contentView);
  49. _content = [UILabel new];
  50. _content.font = NewFont(fitScreenWidth(12));
  51. _content.textColor = [UIColor colorWithString:@"#9A9A9A"];
  52. _content.lineBreakMode = NSLineBreakByTruncatingTail;
  53. _content.numberOfLines = 3;
  54. [self.contentView addSubview:_content];
  55. _content.sd_layout
  56. .leftEqualToView(line1)
  57. .maxHeightIs(fitScreenWidth(50))
  58. .topSpaceToView(line1, 10)
  59. .rightSpaceToView(self.contentView, 15);
  60. UIImageView *followimage = [UIImageView new];
  61. [followimage setImage:NewImageNamed(@"关注")];
  62. [self.contentView addSubview:followimage];
  63. followimage.sd_layout
  64. .rightSpaceToView(self.contentView, 15)
  65. .heightIs(fitScreenWidth(16))
  66. .widthIs(fitScreenWidth(16))
  67. .bottomSpaceToView(self.contentView,5);
  68. _concernsnumber = [UILabel new];
  69. _concernsnumber.font = NewFont(fitScreenWidth(12));
  70. _concernsnumber.textColor = [UIColor colorWithString:@"#9A9A9A"];
  71. [_concernsnumber setSingleLineAutoResizeWithMaxWidth:0];
  72. [self.contentView addSubview:_concernsnumber];
  73. _concernsnumber.sd_layout
  74. .centerYEqualToView(followimage)
  75. .heightIs(16)
  76. .rightSpaceToView(followimage, 5);
  77. }
  78. return self;
  79. }
  80. - (void)assignment:(RecommendModel *)model {
  81. if (model.minLogoUrl == NULL) {
  82. [_image setImage:NewImageNamed(@"推荐默认")];
  83. }else{
  84. [_image sd_setImageWithURL:NewURL([model.minLogoUrl mosaicUrlPrefix]) placeholderImage:NewImageNamed(@"jz")];
  85. }
  86. _title.text = model.name;
  87. _content.text = model.introduce;
  88. _concernsnumber.text = model.interestCount;
  89. }
  90. - (void)awakeFromNib {
  91. [super awakeFromNib];
  92. // Initialization code
  93. }
  94. - (void)setSelected:(BOOL)selected animated:(BOOL)animated {
  95. [super setSelected:selected animated:animated];
  96. // Configure the view for the selected state
  97. }
  98. @end