MHCommentFrame.m 895 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. //
  2. // MHCommentFrame.m
  3. // MHDevelopExample
  4. //
  5. // Created by CoderMikeHe on 17/2/8.
  6. // Copyright © 2017年 CoderMikeHe. All rights reserved.
  7. //
  8. #import "MHCommentFrame.h"
  9. @interface MHCommentFrame ()
  10. /** 内容尺寸 */
  11. @property (nonatomic , assign) CGRect textFrame;
  12. /** cell高度 */
  13. @property (nonatomic , assign) CGFloat cellHeight;
  14. @end
  15. @implementation MHCommentFrame
  16. #pragma mark - Setter
  17. - (void)setComment:(MHComment *)comment
  18. {
  19. _comment = comment;
  20. // 文本内容
  21. CGFloat textX = 0;
  22. CGFloat textY = 0;
  23. CGSize textLimitSize = CGSizeMake(self.maxW, MAXFLOAT);
  24. CGFloat textH = [YYTextLayout layoutWithContainerSize:textLimitSize text:[comment attributedText]].textBoundingSize.height;
  25. self.textFrame = (CGRect){{textX , textY} , {textLimitSize.width , textH}};
  26. self.cellHeight = CGRectGetMaxY(self.textFrame) + 12;
  27. }
  28. @end