NTESSearchLocalHistoryObject.m 1.0 KB

123456789101112131415161718192021222324252627282930313233343536
  1. //
  2. // NTESSearchLocalHistoryObject.m
  3. // NIM
  4. //
  5. // Created by chris on 15/7/8.
  6. // Copyright (c) 2015年 Netease. All rights reserved.
  7. //
  8. #import "NTESSearchLocalHistoryObject.h"
  9. #import "NTESSearchCellLayoutConstant.h"
  10. @implementation NTESSearchLocalHistoryObject
  11. - (instancetype)initWithMessage:(NIMMessage *)message{
  12. self = [super init];
  13. if (self) {
  14. _message = message;
  15. [self calculateHistoryItemHeight];
  16. }
  17. return self;
  18. }
  19. - (void)calculateHistoryItemHeight{
  20. NSString *content = _message.text;
  21. UILabel *label = [[UILabel alloc] initWithFrame:CGRectZero];
  22. label.numberOfLines = 0;
  23. label.font = [UIFont systemFontOfSize:SearchCellContentFontSize];
  24. label.text = content;
  25. CGSize labelSize = [label sizeThatFits:CGSizeMake(SearchCellContentMaxWidth * UISreenWidthScale, CGFLOAT_MAX)];
  26. CGFloat labelHeight = MAX(SearchCellContentMinHeight, labelSize.height);
  27. CGFloat height = labelHeight + SearchCellContentTop + SearchCellContentBottom;
  28. _uiHeight = height;
  29. }
  30. @end