123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130 |
- //
- // PdCommentCell.m
- // FirstLink
- //
- // Created by jack on 15/7/17.
- // Copyright (c) 2015年 FirstLink. All rights reserved.
- //
- #import "PdCommentCell.h"
- #import "CommentItem.h"
- @implementation PdCommentCell
- @synthesize iconImgView = _iconImgView;
- @synthesize nameLabel = _nameLabel;
- @synthesize timeLabel = _timeLabel;
- @synthesize commentLabel = _commentLabel;
- @synthesize bottomLine = _bottomLine;
- - (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
- {
- self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
- if (self) {
- [self initialize];
- self.selectionStyle = UITableViewCellSelectionStyleNone;
- }
- return self;
- }
- - (void)initialize
- {
- UIView *bottomLine = self.bottomLine;
-
- [self.contentView addSubview:self.iconImgView];
- [self.contentView addSubview:self.nameLabel];
- [self.contentView addSubview:self.timeLabel];
- [self.contentView addSubview:self.commentLabel];
- [self.contentView addSubview:bottomLine];
-
- [self.iconImgView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.equalTo(self.contentView).offset(15);
- make.top.equalTo(self.contentView).offset(20);
- make.width.height.equalTo(@40);
- }];
-
- [self.nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.equalTo(self.iconImgView);
- make.left.equalTo(self.iconImgView.mas_right).offset(10);
- make.right.equalTo(self.contentView).offset(- 5);
- }];
-
- [self.timeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.equalTo(self.nameLabel);
- make.bottom.equalTo(self.contentView).offset(- 20);
- }];
-
- [self.commentLabel mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.equalTo(self.nameLabel);
- make.top.equalTo(self.nameLabel.mas_bottom).offset(10);
- make.right.equalTo(self.contentView).offset(- 10);
- }];
-
- [bottomLine mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.equalTo(self.iconImgView);
- make.right.equalTo(self.contentView);
- make.height.equalTo(@0.5);
- make.bottom.equalTo(self.contentView);
- }];
-
- }
- + (CGFloat)cellHeightForCommentText:(NSString *)text
- {
- CGRect rect = [FLStringHelper rectOfString:text font:[UIFont systemFontOfSize:14] width:UISCREENWIDTH - 70];
- CGFloat otherHeight = 90;
- if (rect.size.height == 0) return otherHeight;
- return rect.size.height + otherHeight;
- }
- #pragma mark - getter && setter
- - (UIImageView *)iconImgView
- {
- if (_iconImgView == nil) {
- _iconImgView = [[UIImageView alloc]init];
- _iconImgView.layer.cornerRadius = 20;
- _iconImgView.layer.masksToBounds = YES;
- }
- return _iconImgView;
- }
- - (UILabel *)nameLabel
- {
- if (_nameLabel == nil) {
- _nameLabel = [[UILabel alloc]init];
- _nameLabel.backgroundColor = [UIColor clearColor];
- _nameLabel.font = [UIFont systemFontOfSize:14];
- _nameLabel.textColor = UIColorFromRGB(0x333333);
- _nameLabel.textAlignment = NSTextAlignmentLeft;
- }
- return _nameLabel;
- }
- - (UILabel *)timeLabel
- {
- if (_timeLabel == nil) {
- _timeLabel = [[UILabel alloc]init];
- _timeLabel.backgroundColor = [UIColor clearColor];
- _timeLabel.font = [UIFont systemFontOfSize:10];
- _timeLabel.textColor = UIColorFromRGB(0x999999);
- _timeLabel.textAlignment = NSTextAlignmentRight;
- }
- return _timeLabel;
- }
- - (UILabel *)commentLabel
- {
- if (_commentLabel == nil) {
- _commentLabel = [[UILabel alloc]init];
- _commentLabel.backgroundColor = [UIColor clearColor];
- _commentLabel.font = [UIFont systemFontOfSize:14];
- _commentLabel.textColor = UIColorFromRGB(0x999999);
- _commentLabel.numberOfLines = 0;
- }
- return _commentLabel;
- }
- - (UIView *)bottomLine
- {
- if (_bottomLine == nil) {
- _bottomLine = [[UIView alloc]init];
- _bottomLine.backgroundColor = UIColorFromRGB(0xe5e5e5);
- }
- return _bottomLine;
- }
- @end
|