説明なし

PdCommentCell.m 4.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. //
  2. // PdCommentCell.m
  3. // FirstLink
  4. //
  5. // Created by jack on 15/7/17.
  6. // Copyright (c) 2015年 FirstLink. All rights reserved.
  7. //
  8. #import "PdCommentCell.h"
  9. #import "CommentItem.h"
  10. @implementation PdCommentCell
  11. @synthesize iconImgView = _iconImgView;
  12. @synthesize nameLabel = _nameLabel;
  13. @synthesize timeLabel = _timeLabel;
  14. @synthesize commentLabel = _commentLabel;
  15. @synthesize bottomLine = _bottomLine;
  16. - (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
  17. {
  18. self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
  19. if (self) {
  20. [self initialize];
  21. self.selectionStyle = UITableViewCellSelectionStyleNone;
  22. }
  23. return self;
  24. }
  25. - (void)initialize
  26. {
  27. UIView *bottomLine = self.bottomLine;
  28. [self.contentView addSubview:self.iconImgView];
  29. [self.contentView addSubview:self.nameLabel];
  30. [self.contentView addSubview:self.timeLabel];
  31. [self.contentView addSubview:self.commentLabel];
  32. [self.contentView addSubview:bottomLine];
  33. [self.iconImgView mas_makeConstraints:^(MASConstraintMaker *make) {
  34. make.left.equalTo(self.contentView).offset(15);
  35. make.top.equalTo(self.contentView).offset(20);
  36. make.width.height.equalTo(@40);
  37. }];
  38. [self.nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  39. make.top.equalTo(self.iconImgView);
  40. make.left.equalTo(self.iconImgView.mas_right).offset(10);
  41. make.right.equalTo(self.contentView).offset(- 5);
  42. }];
  43. [self.timeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  44. make.left.equalTo(self.nameLabel);
  45. make.bottom.equalTo(self.contentView).offset(- 20);
  46. }];
  47. [self.commentLabel mas_makeConstraints:^(MASConstraintMaker *make) {
  48. make.left.equalTo(self.nameLabel);
  49. make.top.equalTo(self.nameLabel.mas_bottom).offset(10);
  50. make.right.equalTo(self.contentView).offset(- 10);
  51. }];
  52. [bottomLine mas_makeConstraints:^(MASConstraintMaker *make) {
  53. make.left.equalTo(self.iconImgView);
  54. make.right.equalTo(self.contentView);
  55. make.height.equalTo(@0.5);
  56. make.bottom.equalTo(self.contentView);
  57. }];
  58. }
  59. + (CGFloat)cellHeightForCommentText:(NSString *)text
  60. {
  61. CGRect rect = [FLStringHelper rectOfString:text font:[UIFont systemFontOfSize:14] width:UISCREENWIDTH - 70];
  62. CGFloat otherHeight = 90;
  63. if (rect.size.height == 0) return otherHeight;
  64. return rect.size.height + otherHeight;
  65. }
  66. #pragma mark - getter && setter
  67. - (UIImageView *)iconImgView
  68. {
  69. if (_iconImgView == nil) {
  70. _iconImgView = [[UIImageView alloc]init];
  71. _iconImgView.layer.cornerRadius = 20;
  72. _iconImgView.layer.masksToBounds = YES;
  73. }
  74. return _iconImgView;
  75. }
  76. - (UILabel *)nameLabel
  77. {
  78. if (_nameLabel == nil) {
  79. _nameLabel = [[UILabel alloc]init];
  80. _nameLabel.backgroundColor = [UIColor clearColor];
  81. _nameLabel.font = [UIFont systemFontOfSize:14];
  82. _nameLabel.textColor = UIColorFromRGB(0x333333);
  83. _nameLabel.textAlignment = NSTextAlignmentLeft;
  84. }
  85. return _nameLabel;
  86. }
  87. - (UILabel *)timeLabel
  88. {
  89. if (_timeLabel == nil) {
  90. _timeLabel = [[UILabel alloc]init];
  91. _timeLabel.backgroundColor = [UIColor clearColor];
  92. _timeLabel.font = [UIFont systemFontOfSize:10];
  93. _timeLabel.textColor = UIColorFromRGB(0x999999);
  94. _timeLabel.textAlignment = NSTextAlignmentRight;
  95. }
  96. return _timeLabel;
  97. }
  98. - (UILabel *)commentLabel
  99. {
  100. if (_commentLabel == nil) {
  101. _commentLabel = [[UILabel alloc]init];
  102. _commentLabel.backgroundColor = [UIColor clearColor];
  103. _commentLabel.font = [UIFont systemFontOfSize:14];
  104. _commentLabel.textColor = UIColorFromRGB(0x999999);
  105. _commentLabel.numberOfLines = 0;
  106. }
  107. return _commentLabel;
  108. }
  109. - (UIView *)bottomLine
  110. {
  111. if (_bottomLine == nil) {
  112. _bottomLine = [[UIView alloc]init];
  113. _bottomLine.backgroundColor = UIColorFromRGB(0xe5e5e5);
  114. }
  115. return _bottomLine;
  116. }
  117. @end