CollectionXMCell.m 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. //
  2. // CollectionXMCell.m
  3. // jitao
  4. //
  5. // Created by 罗云飞 on 2018/8/13.
  6. // Copyright © 2018年 罗云飞. All rights reserved.
  7. //
  8. #import "CollectionXMCell.h"
  9. @implementation CollectionXMCell
  10. /*
  11. @property(copy,nonatomic)UIImageView *image;
  12. @property(copy,nonatomic)UILabel *title;
  13. @property(copy,nonatomic)UILabel *CollectionNumber;
  14. @property(copy,nonatomic)UIButton *CollectionBT;
  15. @property(copy,nonatomic)UILabel *CollectionDetail;
  16. @property(copy,nonatomic)UILabel *company;
  17. @property(copy,nonatomic)UILabel *jiage;
  18. */
  19. - (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
  20. self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
  21. if (self) {
  22. _image = [UIImageView new];
  23. [self.contentView addSubview:_image];
  24. _image.sd_layout
  25. .leftSpaceToView(self.contentView, 15)
  26. .topSpaceToView(self.contentView, 20)
  27. .heightIs(65)
  28. .widthIs(100);
  29. _CollectionBT = [UIButton new];
  30. [_CollectionBT setImage:NewImageNamed(@"pj") forState:UIControlStateNormal];
  31. [self.contentView addSubview:_CollectionBT];
  32. _CollectionBT.sd_layout
  33. .rightSpaceToView(self.contentView, 15)
  34. .heightIs(15)
  35. .widthIs(15)
  36. .topEqualToView(_image);
  37. _CollectionNumber = [UILabel new];
  38. [_CollectionNumber setSingleLineAutoResizeWithMaxWidth:0];
  39. _CollectionNumber.textColor = [UIColor colorWithString:@"#AEAEAE"];
  40. _CollectionNumber.font = NewFont(fitScreenWidth(13));
  41. [self.contentView addSubview:_CollectionNumber];
  42. _CollectionNumber.sd_layout
  43. .topEqualToView(_CollectionBT)
  44. .heightIs(15)
  45. .rightSpaceToView(_CollectionBT, 5);
  46. _title = [UILabel new];
  47. _title.font = NewFont(fitScreenWidth(16));
  48. [self.contentView addSubview:_title];
  49. _title.sd_layout
  50. .leftSpaceToView(_image, 10)
  51. .heightIs(15)
  52. .topEqualToView(_image)
  53. .rightSpaceToView(_CollectionNumber, 15);
  54. UILabel *line = [UILabel new];
  55. line.backgroundColor = NewLineGrayColor;
  56. [self.contentView addSubview:line];
  57. line.sd_layout
  58. .leftSpaceToView(_image, 10)
  59. .heightIs(0.8)
  60. .rightSpaceToView(self.contentView, 15)
  61. .topSpaceToView(_title, 7.5);
  62. _CollectionDetail = [UILabel new];
  63. _CollectionDetail.font = NewFont(fitScreenWidth(14));
  64. _CollectionDetail.textColor = [UIColor colorWithString:@"#6C6C6C"];
  65. //设置 label的换行模式
  66. _CollectionDetail.lineBreakMode = NSLineBreakByTruncatingTail; //根据单词进行换行
  67. //设置label显示几行 可以有无限行
  68. _CollectionDetail.numberOfLines = 2;
  69. [self.contentView addSubview:_CollectionDetail];
  70. _CollectionDetail.sd_layout
  71. .leftSpaceToView(_image, 10)
  72. .maxHeightIs(40)
  73. .rightSpaceToView(self.contentView, 30)
  74. .topSpaceToView(line, 7.5);
  75. _jiage = [UILabel new];
  76. _jiage.font = NewFont(fitScreenWidth(15));
  77. _jiage.textColor = NewButtonColor;
  78. [_jiage setSingleLineAutoResizeWithMaxWidth:0];
  79. [self.contentView addSubview:_jiage];
  80. _jiage.sd_layout
  81. .rightSpaceToView(self.contentView, 15)
  82. .heightIs(15)
  83. .bottomSpaceToView(self.contentView, 30);
  84. _company = [UILabel new];
  85. _company.font = NewFont(fitScreenWidth(13));
  86. _company.textColor = [UIColor colorWithString:@"#6C6C6C"];
  87. [_company setSingleLineAutoResizeWithMaxWidth:0];
  88. [self.contentView addSubview:_company];
  89. _company.sd_layout
  90. .leftSpaceToView(_image, 10)
  91. .heightIs(15)
  92. .bottomEqualToView(_jiage);
  93. UILabel *line1 = [UILabel new];
  94. line1.backgroundColor = NewLineGrayColor;
  95. [self.contentView addSubview:line1];
  96. line1.sd_layout
  97. .bottomEqualToView(self.contentView)
  98. .heightIs(10)
  99. .widthIs(SCREEN_WIDTH);
  100. }
  101. return self;
  102. }
  103. - (void)assignment:(NewshoucangModel *)model {
  104. [_image sd_setImageWithURL:NewURL([model.imgUrl mosaicUrlPrefix]) placeholderImage:NewImageNamed(@"服务项目")];
  105. _CollectionNumber.text = model.interestCount;
  106. _title.text = model.name;
  107. _CollectionDetail.text = model.introduction;
  108. if (model.textA == NULL) {
  109. _jiage.text = @"面议";
  110. }else{
  111. _jiage.text = [NSString stringWithFormat:@"¥%@万元",model.textA];
  112. }
  113. _company.text = model.ownerName;
  114. }
  115. - (void)awakeFromNib {
  116. [super awakeFromNib];
  117. // Initialization code
  118. }
  119. - (void)setSelected:(BOOL)selected animated:(BOOL)animated {
  120. [super setSelected:selected animated:animated];
  121. // Configure the view for the selected state
  122. }
  123. @end