2
0

WFCFavoriteBaseCell.m 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. //
  2. // WFCFavoriteBaseCell.m
  3. // WildFireChat
  4. //
  5. // Created by Tom Lee on 2020/11/1.
  6. // Copyright © 2020 WildFireChat. All rights reserved.
  7. //
  8. #import "WFCFavoriteBaseCell.h"
  9. @interface WFCFavoriteBaseCell ()
  10. @property(nonatomic, strong)UILabel *buttomLabel;
  11. @end
  12. @implementation WFCFavoriteBaseCell
  13. - (void)awakeFromNib {
  14. [super awakeFromNib];
  15. // Initialization code
  16. for (UIView *subView in self.subviews) {
  17. [subView removeFromSuperview];
  18. }
  19. }
  20. - (void)setFavoriteItem:(WFCUFavoriteItem *)favoriteItem {
  21. _favoriteItem = favoriteItem;
  22. CGFloat contentHeight = [[self class] contentHeight:favoriteItem];
  23. self.contentArea.frame = CGRectMake(16, 16, [UIScreen mainScreen].bounds.size.width - 16, contentHeight);
  24. self.buttomLabel.frame = CGRectMake(16, contentHeight+24, self.bounds.size.width-32, 16);
  25. self.buttomLabel.text = [favoriteItem.origin stringByAppendingFormat:@" %@", [WFCUUtilities formatTimeLabel:favoriteItem.timestamp]];
  26. }
  27. + (CGFloat)contentHeight:(WFCUFavoriteItem *)favoriteItem {
  28. return 0;
  29. }
  30. + (CGFloat)heightOf:(WFCUFavoriteItem *)favoriteItem {
  31. return [self contentHeight:favoriteItem] + 54;
  32. }
  33. - (UIView *)contentArea {
  34. if (!_contentArea) {
  35. _contentArea = [[UIView alloc] init];
  36. [self.contentView addSubview:_contentArea];
  37. }
  38. return _contentArea;;
  39. }
  40. - (UILabel *)buttomLabel {
  41. if (!_buttomLabel) {
  42. _buttomLabel = [[UILabel alloc] init];
  43. _buttomLabel.numberOfLines = 1;
  44. _buttomLabel.font = [UIFont systemFontOfSize:14];
  45. _buttomLabel.textColor = [UIColor grayColor];
  46. _buttomLabel.lineBreakMode = NSLineBreakByTruncatingMiddle;
  47. [self.contentView addSubview:_buttomLabel];
  48. }
  49. return _buttomLabel;;
  50. }
  51. @end