WFCUCompositeTextCell.m 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. //
  2. // CompositeTextTableViewCell.m
  3. // WFChatUIKit
  4. //
  5. // Created by Tom Lee on 2020/10/4.
  6. // Copyright © 2020 WildFireChat. All rights reserved.
  7. //
  8. #import "WFCUCompositeTextCell.h"
  9. #import <WFChatClient/WFCChatClient.h>
  10. #import "WFCUUtilities.h"
  11. @implementation WFCUCompositeTextCell
  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. WFCCTextMessageContent *txtContent = (WFCCTextMessageContent *)message.content;
  22. CGRect frame = [self.class contentFrame];
  23. CGSize size = [WFCUUtilities getTextDrawingSize:txtContent.text font:[UIFont systemFontOfSize:18] constrainedSize:CGSizeMake(frame.size.width, 8000)];
  24. return size.height;
  25. }
  26. - (void)setMessage:(WFCCMessage *)message {
  27. [super setMessage:message];
  28. WFCCTextMessageContent *txtCnt = (WFCCTextMessageContent *)message.content;
  29. CGRect frame = [self.class contentFrame];
  30. frame.size.height = [self.class heightForMessageContent:message];
  31. self.contentLabel.frame = frame;
  32. self.contentLabel.text = txtCnt.text;
  33. }
  34. - (UILabel *)contentLabel {
  35. if (!_contentLabel) {
  36. _contentLabel = [[UILabel alloc] initWithFrame:CGRectZero];
  37. _contentLabel.numberOfLines = 0;
  38. [self.contentView addSubview:_contentLabel];
  39. }
  40. return _contentLabel;
  41. }
  42. @end