WFCUCompositeUnknownCell.m 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. //
  2. // WFCUCompositeUnknownCell.h.m
  3. // WFChatUIKit
  4. //
  5. // Created by Tom Lee on 2020/10/4.
  6. // Copyright © 2020 WildFireChat. All rights reserved.
  7. //
  8. #import "WFCUCompositeUnknownCell.h"
  9. #import <WFChatClient/WFCChatClient.h>
  10. #import "WFCUUtilities.h"
  11. @implementation WFCUCompositeUnknownCell
  12. - (void)awakeFromNib {
  13. [super awakeFromNib];
  14. // Initialization code
  15. }
  16. - (void)setSelected:(BOOL)selected animated:(BOOL)animated {
  17. [super setSelected:selected animated:animated];
  18. // Configure the view for the selected state
  19. }
  20. + (CGFloat)heightForMessageContent:(WFCCMessage *)message {
  21. CGRect frame = [self.class contentFrame];
  22. CGSize size = [WFCUUtilities getTextDrawingSize:[message.content digest:message] font:[UIFont systemFontOfSize:18] constrainedSize:CGSizeMake(frame.size.width, 8000)];
  23. return size.height;
  24. }
  25. - (void)setMessage:(WFCCMessage *)message {
  26. [super setMessage:message];
  27. CGRect frame = [self.class contentFrame];
  28. frame.size.height = [self.class heightForMessageContent:message];
  29. self.contentLabel.frame = frame;
  30. self.contentLabel.text = [message.content digest:message];
  31. }
  32. - (UILabel *)contentLabel {
  33. if (!_contentLabel) {
  34. _contentLabel = [[UILabel alloc] initWithFrame:CGRectZero];
  35. _contentLabel.numberOfLines = 0;
  36. [self.contentView addSubview:_contentLabel];
  37. }
  38. return _contentLabel;
  39. }
  40. @end