CollectionCGCell.m 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  1. //
  2. // CollectionCGCell.m
  3. // jitao
  4. //
  5. // Created by 罗云飞 on 2018/8/13.
  6. // Copyright © 2018年 罗云飞. All rights reserved.
  7. //
  8. #import "CollectionCGCell.h"
  9. @implementation CollectionCGCell
  10. - (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
  11. self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
  12. if (self) {
  13. _title = [UILabel new];
  14. _title.font = NewFont(fitScreenWidth(16));
  15. [_title setSingleLineAutoResizeWithMaxWidth:0];
  16. [self.contentView addSubview:_title];
  17. _title.sd_layout
  18. .leftSpaceToView(self.contentView, 15)
  19. .topSpaceToView(self.contentView, 20)
  20. .heightIs(15);
  21. UILabel *line = [UILabel new];
  22. line.backgroundColor = NewLineGrayColor;
  23. [self.contentView addSubview:line];
  24. line.sd_layout
  25. .leftSpaceToView(self.contentView, 15)
  26. .rightSpaceToView(self.contentView, 15)
  27. .heightIs(0.8)
  28. .topSpaceToView(_title, 5);
  29. _titledetail = [UILabel new];
  30. _titledetail.font = NewFont(fitScreenWidth(14));
  31. _titledetail.textColor = [UIColor colorWithString:@"#6C6C6C"];
  32. //设置 label的换行模式
  33. _titledetail.lineBreakMode = NSLineBreakByTruncatingTail; //根据单词进行换行
  34. //设置label显示几行 可以有无限行
  35. _titledetail.numberOfLines = 2;
  36. [self.contentView addSubview:_titledetail];
  37. _titledetail.sd_layout
  38. .leftSpaceToView(self.contentView, 15)
  39. .rightSpaceToView(self.contentView, 15)
  40. .maxHeightIs(40)
  41. .topSpaceToView(_title, 15);
  42. // for (int i = 0; i<2; i++) {
  43. _label = [UILabel new];
  44. _label.textColor = NewButtonColor;
  45. _label.font = NewFont(fitScreenWidth(13));
  46. ViewBorderRadius(_label, 3, 1, NewButtonColor);
  47. _label.textAlignment = NSTextAlignmentCenter;
  48. [self.contentView addSubview:_label];
  49. // }
  50. _label1 = [UILabel new];
  51. _label1.textColor = NewButtonColor;
  52. _label1.font = NewFont(fitScreenWidth(13));
  53. ViewBorderRadius(_label1, 3, 1, NewButtonColor);
  54. _label1.textAlignment = NSTextAlignmentCenter;
  55. [self.contentView addSubview:_label1];
  56. UILabel *line1 = [UILabel new];
  57. line1.backgroundColor = NewLineGrayColor;
  58. [self.contentView addSubview:line1];
  59. line1.sd_layout
  60. .bottomEqualToView(self.contentView)
  61. .heightIs(10)
  62. .widthIs(SCREEN_WIDTH);
  63. _CollectionBT = [UIButton new];
  64. _CollectionBT.backgroundColor = NewClearColor;
  65. [_CollectionBT setImage:NewImageNamed(@"pj") forState:UIControlStateNormal];
  66. [self.contentView addSubview:_CollectionBT];
  67. _CollectionBT.sd_layout
  68. .bottomSpaceToView(line1, 15)
  69. .heightIs(15)
  70. .widthIs(15)
  71. .rightSpaceToView(self.contentView, 15);
  72. _CollectionNumber = [UILabel new];
  73. _CollectionNumber.textColor = [UIColor colorWithString:@"#6C6C6C"];
  74. _CollectionNumber.font = NewFont(fitScreenWidth(14));
  75. [_CollectionNumber setSingleLineAutoResizeWithMaxWidth:0];
  76. [self.contentView addSubview:_CollectionNumber];
  77. _CollectionNumber.sd_layout
  78. .centerYEqualToView(_CollectionBT)
  79. .heightIs(fitScreenWidth(15))
  80. .rightSpaceToView(_CollectionBT, 2);
  81. }
  82. return self;
  83. }
  84. - (void)assignment:(NewshoucangModel *)model type:(NSString *)type{
  85. _title.text = model.name;
  86. _titledetail.text = model.introduction;
  87. _CollectionNumber.text = model.interestCount;
  88. if (model.fieidA == NULL) {
  89. CGFloat with = [NewUtils heightforString:@"未知行业" andHeight:20 fontSize:fitScreenWidth(13)];
  90. _label.frame = CGRectMake(15+(0*(with+16)), 100, with+8, 20);
  91. _label.text = @"位置行业";
  92. }else{
  93. CGFloat with = [NewUtils heightforString:model.fieidA andHeight:20 fontSize:fitScreenWidth(13)];
  94. _label.frame = CGRectMake(15+(0*(with+16)), 100, with+8, 20);
  95. _label.text = model.fieidA;
  96. }
  97. if ([type isEqualToString:@"成果"]) {
  98. if ([model.textA isEqualToString:@"0"]) {
  99. _label1.text = @"正在研发";
  100. CGFloat with1 = [NewUtils heightforString:@"正在研发" andHeight:20 fontSize:fitScreenWidth(13)];
  101. _label1.frame = CGRectMake(_label.frame.size.width+15+10, 100, with1+8, 20);
  102. }else if ([model.textA isEqualToString:@"1"]){
  103. _label1.text = @"已有样品";
  104. CGFloat with1 = [NewUtils heightforString:@"已有样品" andHeight:20 fontSize:fitScreenWidth(13)];
  105. _label1.frame = CGRectMake(_label.frame.size.width+15+10, 100, with1+8, 20);
  106. }else if ([model.textA isEqualToString:@"2"]){
  107. _label1.text = @"通过小试";
  108. CGFloat with1 = [NewUtils heightforString:@"通过小试" andHeight:20 fontSize:fitScreenWidth(13)];
  109. _label1.frame = CGRectMake(_label.frame.size.width+15+10, 100, with1+8, 20);
  110. }else if ([model.textA isEqualToString:@"3"]){
  111. _label1.text = @"通过小试";
  112. CGFloat with1 = [NewUtils heightforString:@"通过小试" andHeight:20 fontSize:fitScreenWidth(13)];
  113. _label1.frame = CGRectMake(_label.frame.size.width+15+10, 100, with1+8, 20);
  114. }else if ([model.textA isEqualToString:@"4"]){
  115. _label1.text = @"可以量产";
  116. CGFloat with1 = [NewUtils heightforString:@"可以量产" andHeight:20 fontSize:fitScreenWidth(13)];
  117. _label1.frame = CGRectMake(_label.frame.size.width+15+10, 100, with1+8, 20);
  118. }else{
  119. _label1.text = @"未知成熟度";
  120. CGFloat with1 = [NewUtils heightforString:@"未知成熟度" andHeight:20 fontSize:fitScreenWidth(13)];
  121. _label1.frame = CGRectMake(_label.frame.size.width+15+10, 100, with1+8, 20);
  122. }
  123. }else if ([type isEqualToString:@"需求"]){
  124. if ([model.textA isEqualToString:@"1"]) {
  125. _label1.text = @"加急";
  126. _label1.textColor = NewOrangeColor;
  127. CGFloat with1 = [NewUtils heightforString:@"加急" andHeight:20 fontSize:fitScreenWidth(13)];
  128. _label1.frame = CGRectMake(_label.frame.size.width+15+10, 100, with1+8, 20);
  129. ViewBorderRadius(_label1, 0, 0, NewClearColor);
  130. }else{
  131. }
  132. }
  133. }
  134. - (void)awakeFromNib {
  135. [super awakeFromNib];
  136. // Initialization code
  137. }
  138. - (void)setSelected:(BOOL)selected animated:(BOOL)animated {
  139. [super setSelected:selected animated:animated];
  140. // Configure the view for the selected state
  141. }
  142. @end