FavCell.m 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. //
  2. // FavCell.m
  3. // jiaPei
  4. //
  5. // Created by apple on 15/12/12.
  6. // Copyright © 2015年 JCZ. All rights reserved.
  7. //
  8. #import "FavCell.h"
  9. @interface FavCell()
  10. /**用于显示驾考圈3字。取代detailLabel的。
  11. */
  12. @property (nonatomic,strong) UILabel *lblTag;
  13. @property (nonatomic,strong) UILabel *nameLabel;
  14. @end
  15. @implementation FavCell
  16. - (void)awakeFromNib {
  17. // Initialization code
  18. [super awakeFromNib];
  19. }
  20. - (void)setSelected:(BOOL)selected animated:(BOOL)animated {
  21. [super setSelected:selected animated:animated];
  22. }
  23. +(FavCell*)cellForTableView:(UITableView*)tableView
  24. {
  25. FavCell* cell = [tableView dequeueReusableCellWithIdentifier:@"FavCell"];
  26. if (!cell) {
  27. cell = [[FavCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:@"FavCell"];
  28. [cell.textLabel setTextColor:kTitleColor];
  29. [cell.textLabel setFont:[UIFont scaleSize:15]];
  30. [cell.textLabel setNumberOfLines:0];
  31. UILabel *label = [UILabel new];
  32. [cell addSubview:label];
  33. cell.lblTag = label;
  34. [cell.lblTag setFont:[UIFont scaleSize:13]];
  35. [cell.lblTag setTextAlignment:NSTextAlignmentCenter];
  36. [cell.lblTag setBackgroundColor:defGreen];
  37. [cell.lblTag setTextColor:[UIColor whiteColor]];
  38. [cell.lblTag borderColor:defGreen width:.01 cornorRadios:3];
  39. label = [UILabel new];
  40. [cell addSubview:label];
  41. cell.nameLabel = label;
  42. [cell.nameLabel setTextColor:kTitleColor];
  43. [cell.nameLabel setFont:[UIFont scaleSize:17]];
  44. }
  45. return cell;
  46. }
  47. -(void)setModel:(NSDictionary *)model
  48. {
  49. _model = model;
  50. [self.textLabel setText:model[@"CONTENT"]];
  51. [self.lblTag setText:model[@"GROUPNAME"]];
  52. if ([model[@"GROUPNAME"] isEqualToString:@""])
  53. {
  54. [self.lblTag setText:@"社区"];
  55. }
  56. self.nameLabel.text = model[@"NAME"];
  57. }
  58. /**上,下,左右。内间距。都是20
  59. */
  60. -(void)layoutSubviews
  61. {
  62. [super layoutSubviews];
  63. CGFloat x,y,w,h,bd;
  64. bd = 20;
  65. x = bd;
  66. y = 10;
  67. w = 200;
  68. h = 20;
  69. [self.nameLabel setFrame:CGRectMake(x, y, w, h)];
  70. y += 10 + h;
  71. w = kSize.width - bd*2;
  72. h = [self.textLabel.text heightForWid:w Font:15];
  73. [self.textLabel setFrame:CGRectMake(x, y, w, h)];
  74. y += h +bd;
  75. w = [self.lblTag.text sizeForFont:13].width + 15;
  76. h = [self.lblTag.text sizeForFont:13].height + 10;
  77. [self.lblTag setFrame:CGRectMake(x, y, w, h)];
  78. // w = [self.detailTextLabel.text sizeForFont:13].width + 15;
  79. // h = [self.detailTextLabel.text sizeForFont:13].height + 10;
  80. // [self.detailTextLabel setFrame:CGRectMake(x, y, w, h)];
  81. }
  82. @end
  83. CGFloat FavCellHeightByDict(NSDictionary* dict)
  84. {
  85. if (!dict) {
  86. return .1;
  87. }
  88. CGFloat w,h,bd;
  89. bd = 20;
  90. w = kSize.width - bd*2;
  91. h = [dict[@"CONTENT"] heightForWid:w Font:15] + bd;
  92. h += [@"驾考" sizeForFont:13].height + 40 + bd;
  93. return h;
  94. }