HomeSchoolCell.m 3.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. //
  2. // HomeSchoolCell.m
  3. // smartRhino
  4. //
  5. // Created by niuzhen on 2020/5/16.
  6. // Copyright © 2020 tederen. All rights reserved.
  7. //
  8. #import "HomeSchoolCell.h"
  9. @implementation HomeSchoolCell
  10. - (void)awakeFromNib {
  11. [super awakeFromNib];
  12. self.addressL.layer.cornerRadius = 2.f;
  13. self.addressL.layer.masksToBounds = YES;
  14. self.addressL.backgroundColor = UIColorHex(0xF4F4F4);
  15. self.numL.layer.cornerRadius = 2.f;
  16. self.numL.layer.masksToBounds = YES;
  17. self.numL.backgroundColor = UIColorHex(0xF4F4F4);
  18. self.levelL.layer.cornerRadius = 2.f;
  19. self.levelL.layer.masksToBounds = YES;
  20. self.levelL.backgroundColor = UIColorHex(0xF4F4F4);
  21. }
  22. - (void)setSelected:(BOOL)selected animated:(BOOL)animated {
  23. [super setSelected:selected animated:animated];
  24. // Configure the view for the selected state
  25. }
  26. + (HomeSchoolCell *)configCell0:(UITableView *)tableView indexPath:(NSIndexPath *)indexPath{
  27. static NSString *cellIdentifer = @"HomeSchoolCell0";
  28. HomeSchoolCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifer];
  29. if (cell == nil) {
  30. cell = [[[NSBundle mainBundle] loadNibNamed:@"HomeSchoolCell" owner:nil options:nil] objectAtIndex:0];
  31. }
  32. return cell;
  33. }
  34. + (HomeSchoolCell *)configCell1:(UITableView *)tableView indexPath:(NSIndexPath *)indexPath{
  35. static NSString *cellIdentifer = @"HomeSchoolCell1";
  36. HomeSchoolCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifer];
  37. if (cell == nil) {
  38. cell = [[[NSBundle mainBundle] loadNibNamed:@"HomeSchoolCell" owner:nil options:nil] objectAtIndex:1];
  39. }
  40. return cell;
  41. }
  42. - (void)setDataModel:(HomeSubItemModel *)model
  43. {
  44. [self.imagV sd_setImageWithURL:[NSURL URLWithString:model.ImageUrl] placeholderImage:kPlaceHolderImage];
  45. self.titleL.text = model.Name;
  46. self.subTitleL.text = model.ExtendLableName;
  47. if ([model.LableName isKindOfClass:[NSArray class]]) {
  48. NSArray * array = model.LableName;
  49. if (array.count == 3) {
  50. self.addressL.text = array[0];
  51. self.numL.text = array[1];
  52. self.levelL.text = array[2];
  53. }
  54. }else if([model.LableName isKindOfClass:[NSString class]]){
  55. NSString * str = model.LableName;
  56. NSArray *array = [str componentsSeparatedByString:@","];
  57. self.addressL.text = array[0];
  58. self.numL.text = array[1];
  59. self.levelL.text = array[2];
  60. }
  61. self.addW.constant = [self addPlaceLabel:self.addressL];
  62. self.numW.constant = [self addPlaceLabel:self.numL];
  63. self.levelW.constant = [self addPlaceLabel:self.levelL];
  64. }
  65. - (void)setDataIndexModel:(HomeSubItemModel *)model searchText:(NSString *)text
  66. {
  67. [self.imagV sd_setImageWithURL:[NSURL URLWithString:model.ImageUrls] placeholderImage:kPlaceHolderImage];
  68. self.titleL.attributedText = [ZYCTool checkOfString:model.Title withSearchText:text withColor:UIColorHex(0xFF5252)];
  69. self.addressL.text = @"北京";
  70. self.numL.text = @"特级教师36人";
  71. self.levelL.text = @"小学、初中";
  72. self.subTitleL.hidden = YES;
  73. self.subContant.constant = 0.f;
  74. self.subTopContant.constant = 0.f;
  75. self.subBottomContant.constant = 0.f;
  76. self.addW.constant = [self addPlaceLabel:self.addressL];
  77. self.numW.constant = [self addPlaceLabel:self.numL];
  78. self.levelW.constant = [self addPlaceLabel:self.levelL];
  79. }
  80. - (CGFloat)addPlaceLabel:(UILabel *)label
  81. {
  82. CGFloat W = [label sizeThatFits:CGSizeMake(SCREEN_WIDTH, 18)].width + 16;
  83. return W;
  84. }
  85. @end