ChatTradeCell.m 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. //
  2. // ChatTradeCell.m
  3. // BuguLive
  4. //
  5. // Created by 朱庆彬 on 2017/8/22.
  6. // Copyright © 2017年 xfg. All rights reserved.
  7. //
  8. #import "ChatTradeCell.h"
  9. @implementation ChatTradeCell
  10. {
  11. BOOL _select;
  12. }
  13. - (void)awakeFromNib
  14. {
  15. [super awakeFromNib];
  16. self.mMsg_LabRight_Constraint.constant = 8;
  17. [self.mheadimg.layer setMasksToBounds:YES];
  18. [self.mheadimg.layer setCornerRadius:45 / 2];
  19. self.mheadimg.layer.borderWidth = 1;
  20. self.mheadimg.layer.borderColor = [UIColor whiteColor].CGColor;
  21. self.mmsg.font = kAppMiddleTextFont;
  22. }
  23. //判断信息的高度
  24. - (CGFloat)judge:(NSString *)msg
  25. {
  26. CGFloat msgHeight = [self boundingRectWithSize:msg withLabelWidth:kScreenW - 69];
  27. NSString *str1 = @"1";
  28. CGFloat height = [self boundingRectWithSize:str1 withLabelWidth:kScreenW - 69];
  29. if (msgHeight == height)
  30. {
  31. [self.mdownImg setHidden:YES]; //隐藏
  32. }
  33. else
  34. {
  35. [self.mdownImg setHidden:NO];
  36. self.mMsg_LabRight_Constraint.constant = 38;
  37. }
  38. return msgHeight;
  39. }
  40. //计算文本高度
  41. - (CGFloat)boundingRectWithSize:(NSString *)str withLabelWidth:(CGFloat)width
  42. {
  43. //69是约束的长度
  44. CGRect rect = [str boundingRectWithSize:CGSizeMake(width, MAXFLOAT) options:NSStringDrawingUsesLineFragmentOrigin attributes:@{ NSFontAttributeName: kAppMiddleTextFont } context:nil];
  45. CGFloat height = rect.size.height;
  46. return height;
  47. }
  48. - (void)setSelected:(BOOL)selected animated:(BOOL)animated
  49. {
  50. [super setSelected:selected animated:animated];
  51. // Configure the view for the selected state
  52. }
  53. //cell是否展开 0未展开1展开
  54. - (void)setContentFlag:(NSString *)contentFlag
  55. {
  56. if ([contentFlag isEqualToString:@"0"])
  57. {
  58. _mmsg.numberOfLines = 1;
  59. CGAffineTransform transform = CGAffineTransformMakeRotation(M_PI * 2);
  60. _mdownImg.transform = transform;
  61. }
  62. else
  63. {
  64. _mmsg.numberOfLines = 0;
  65. CGAffineTransform transform = CGAffineTransformMakeRotation(M_PI);
  66. _mdownImg.transform = transform;
  67. }
  68. }
  69. @end