HomeTeacherCell.m 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. //
  2. // HomeTeacherCell.m
  3. // smartRhino
  4. //
  5. // Created by niuzhen on 2020/6/10.
  6. // Copyright © 2020 tederen. All rights reserved.
  7. //
  8. #import "HomeTeacherCell.h"
  9. @implementation HomeTeacherCell
  10. - (void)awakeFromNib {
  11. [super awakeFromNib];
  12. self.collectBtn.layer.cornerRadius = 4.f;
  13. self.collectBtn.layer.borderWidth = 0.5f;
  14. self.collectBtn.layer.borderColor = UIColorHex(0xBBBBBB).CGColor;
  15. self.collectBtn.layer.masksToBounds = YES;
  16. }
  17. - (void)setSelected:(BOOL)selected animated:(BOOL)animated {
  18. [super setSelected:selected animated:animated];
  19. // Configure the view for the selected state
  20. }
  21. + (HomeTeacherCell *)configCell:(UITableView *)tableView indexPath:(NSIndexPath *)indexPath{
  22. static NSString *cellIdentifer = @"HomeTeacherCell";
  23. HomeTeacherCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifer];
  24. if (cell == nil) {
  25. cell = [[[NSBundle mainBundle] loadNibNamed:@"HomeTeacherCell" owner:nil options:nil] objectAtIndex:0];
  26. }
  27. return cell;
  28. }
  29. - (void)setDataWithModel:(HomeSubItemModel *)model
  30. {
  31. [self.imagV sd_setImageWithURL:[NSURL URLWithString:model.ImageUrl] placeholderImage:IMG(@"img_placeHolder")];
  32. self.subTitleL.text = ISEmpty(model.Job) ? @"" : model.Job;
  33. self.nameL.text = ISEmpty(model.Name) ? @"" : model.Name;
  34. self.countl.text = [NSString stringWithFormat:@"收藏量:%ld",model.CollectCount];
  35. if (model.IsCollect) {
  36. self.collectBtn.layer.borderColor = UIColorHex(0xBBBBBB).CGColor;
  37. [self.collectBtn setTitleColor:UIColorHex(0xBBBBBB) forState:UIControlStateNormal];
  38. [self.collectBtn setTitle:@"已收藏" forState:UIControlStateNormal];
  39. }else{
  40. self.collectBtn.layer.borderColor = UIColorHex(0x13A3FF).CGColor;
  41. [self.collectBtn setTitleColor:UIColorHex(0x13A3FF) forState:UIControlStateNormal];
  42. [self.collectBtn setTitle:@"收藏" forState:UIControlStateNormal];
  43. }
  44. WS(weakSelf);
  45. [self.collectBtn setAction:^{
  46. if (weakSelf.ClickCollectBlock) {
  47. weakSelf.ClickCollectBlock(model.Id);
  48. }
  49. }];
  50. }
  51. - (void)setDataWithModel:(HomeSubItemModel *)model searchText:(NSString *)text
  52. {
  53. [self.imagV sd_setImageWithURL:[NSURL URLWithString:model.ImageUrls] placeholderImage:IMG(@"img_placeHolder")];
  54. self.subTitleL.text = model.Summary;
  55. self.nameL.attributedText = [ZYCTool checkOfString:model.Title withSearchText:text withColor:UIColorHex(0xFF5252)];
  56. self.countl.text = [NSString stringWithFormat:@"收藏:%ld",model.CollectCount];
  57. self.collectBtn.hidden = YES;
  58. }
  59. @end