MyattentionCell.m 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. //
  2. // MyattentionCell.m
  3. // jitao
  4. //
  5. // Created by 罗云飞 on 2017/12/9.
  6. // Copyright © 2017年 罗云飞. All rights reserved.
  7. //
  8. #import "MyattentionCell.h"
  9. @implementation MyattentionCell
  10. - (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
  11. self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
  12. if (self) {
  13. _image = [UIImageView new];
  14. ViewRadius(_image, fitScreenWidth(38)/2);
  15. [self.contentView addSubview:_image];
  16. _image.sd_layout
  17. .leftSpaceToView(self.contentView, 15)
  18. .centerYEqualToView(self.contentView)
  19. .widthIs(fitScreenWidth(38))
  20. .heightIs(fitScreenWidth(38));
  21. _title = [UILabel new];
  22. _title.font = NewFont(fitScreenWidth(15));
  23. _title.textColor = NewBlackColor;
  24. _title.lineBreakMode = NSLineBreakByTruncatingTail;
  25. _title.numberOfLines = 1;
  26. [self.contentView addSubview:_title];
  27. _title.sd_layout
  28. .leftSpaceToView(_image, fitScreenWidth(8))
  29. .topEqualToView(_image)
  30. .heightIs(fitScreenWidth(15))
  31. .rightSpaceToView(self.contentView, fitScreenWidth(70));
  32. UILabel *line = [UILabel new];
  33. line.backgroundColor = NewLineGrayColor;
  34. [self.contentView addSubview:line];
  35. line.sd_layout
  36. .bottomEqualToView(self.contentView)
  37. .heightIs(0.8)
  38. .leftEqualToView(self.contentView)
  39. .rightEqualToView(self.contentView);
  40. _time = [UILabel new];
  41. _time.textColor = [UIColor colorWithString:@"#9A9A9A"];
  42. _time.font = NewFont(fitScreenWidth(11));
  43. [_time setSingleLineAutoResizeWithMaxWidth:0];
  44. [self.contentView addSubview:_time];
  45. _time.sd_layout
  46. .leftEqualToView(_title)
  47. .bottomSpaceToView(self.contentView, fitScreenWidth(15))
  48. .heightIs(fitScreenWidth(10));
  49. _follow = [UIButton new];
  50. [_follow setImage:[UIImage imageNamed:@"关注"] forState:UIControlStateNormal];
  51. [self.contentView addSubview:_follow];
  52. _follow.sd_layout
  53. .rightSpaceToView(self.contentView, 30)
  54. .centerYEqualToView(self.contentView)
  55. .heightIs(16)
  56. .widthIs(16);
  57. _countInterest = [UILabel new];
  58. _countInterest.font = NewFont(fitScreenWidth(12));
  59. [_countInterest setSingleLineAutoResizeWithMaxWidth:0];
  60. [self.contentView addSubview:_countInterest];
  61. _countInterest.sd_layout
  62. .centerYEqualToView(_time)
  63. .heightIs(15)
  64. .centerXEqualToView(_follow);
  65. }
  66. return self;
  67. }
  68. - (void)assignment:(MyattentionModel *)model {
  69. _title.text = model.name;
  70. _time.text = model.createTimeFormattedDate;
  71. if ([model.type isEqualToString:@"0"]) {
  72. [_image setImage:[UIImage imageNamed:@"成果"]];
  73. }else if ([model.type isEqualToString:@"1"]){
  74. [_image setImage:[UIImage imageNamed:@"需求"]];
  75. }else if ([model.type isEqualToString:@"2"]){
  76. [_image setImage:[UIImage imageNamed:@"专家"]];
  77. }else if ([model.type isEqualToString:@"7"]){
  78. [_image setImage:[UIImage imageNamed:@"咨询师"]];
  79. }else if ([model.type isEqualToString:@"5"]){
  80. [_image setImage:[UIImage imageNamed:@"项目"]];
  81. }
  82. _countInterest.text = model.countInterest;
  83. }
  84. - (void)awakeFromNib {
  85. [super awakeFromNib];
  86. // Initialization code
  87. }
  88. - (void)setSelected:(BOOL)selected animated:(BOOL)animated {
  89. [super setSelected:selected animated:animated];
  90. // Configure the view for the selected state
  91. }
  92. @end