CommentSubModel.m 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. //
  2. // CommentSubModel.m
  3. // smartRhino
  4. //
  5. // Created by tederen on 2019/10/29.
  6. // Copyright © 2019 tederen. All rights reserved.
  7. //
  8. #import "CommentSubModel.h"
  9. @implementation CommentSubModel
  10. - (CGFloat)getCellHeight{
  11. UILabel *textLabel = [UILabel new];
  12. textLabel.numberOfLines = 0;
  13. textLabel.font = [UIFont systemFontOfSize:17.5f];
  14. CGFloat height = 0;
  15. if (ISEmptyString(self.ReplyName)) {
  16. textLabel.text = [NSString stringWithFormat:@"%@:%@",self.Name,self.Content];
  17. }else{
  18. textLabel.text = [NSString stringWithFormat:@"%@ 回复 %@:%@",self.Name,self.ReplyName,self.Content];
  19. }
  20. if (!ISEmptyString(self.Content)){
  21. [ZYCTool setLabel:textLabel withSpace:10.f withFont:textLabel.font setLineSpace:0 setTextSpace:2.f];
  22. }
  23. CGFloat nameWith = [self calculateName:self.Name];
  24. CGFloat withFloat = kGXScreenWidth-68-28 - nameWith;
  25. CGSize textSize = [textLabel sizeThatFits:CGSizeMake(withFloat, MAXFLOAT)];
  26. height += textSize.height + 15;
  27. return height;
  28. }
  29. - (CGFloat)calculateName:(NSString *)name{
  30. UILabel *textLabel = [UILabel new];
  31. textLabel.numberOfLines = 0;
  32. textLabel.font = [UIFont systemFontOfSize:17.5f];
  33. textLabel.text = [NSString stringWithFormat:@"%@:",name];
  34. CGSize textSize = [textLabel sizeThatFits:CGSizeMake(kGXScreenWidth, MAXFLOAT)];
  35. return textSize.width;
  36. }
  37. @end