123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173 |
- //
- // ComentSubCell.m
- // smartRhino
- //
- // Created by tederen on 2019/10/29.
- // Copyright © 2019 tederen. All rights reserved.
- //
- #import "ComentSubCell.h"
- #import "CommentSubModel.h"
- @interface ComentSubCell ()
- @property (nonatomic, strong) UIImageView *portraitImgVi;
- @property (nonatomic, strong) UILabel *nameLabel;
- @property (nonatomic, strong) UILabel *secondNameLabel;
- @property (nonatomic, strong) UILabel *timeLabel;
- @property (nonatomic, strong) UILabel *contentLabel;
- @property (nonatomic, strong) UILabel *huifuLabel;
- @end
- @implementation ComentSubCell
- - (void)awakeFromNib {
- [super awakeFromNib];
- // Initialization code
- }
- - (void)loadCommentSubModelData:(CommentSubModel *)model{
- CGFloat herizonSpace = 8;
- CGFloat leftMargin = 0;
- CGFloat rightMargin = 21;
- // CGFloat verticalSpace = 14.5;
- if (!ISEmptyString(model.ReplyName)) {
-
- _nameLabel.text = model.Name;
- _nameLabel.textColor = UIColorHex(1F87DB);
- [ZYCTool setLabel:_nameLabel withSpace:10 withFont:[UIFont systemFontOfSize:17.f] setLineSpace:0 setTextSpace:2];
- CGSize nameSize = [_nameLabel sizeThatFits:CGSizeMake(kGXScreenWidth - 68 ,MAXFLOAT)];
- _nameLabel.frame = CGRectMake(leftMargin,2,nameSize.width, nameSize.height);
-
- _huifuLabel.text = @"回复";
- _huifuLabel.textColor = UIColorHex(636363);
- [ZYCTool setLabel:_huifuLabel withSpace:10 withFont:[UIFont systemFontOfSize:17.f] setLineSpace:0 setTextSpace:2];
- CGSize huifuSize = [_huifuLabel sizeThatFits:CGSizeZero];
- _huifuLabel.frame = CGRectMake(CGRectGetMaxX(_nameLabel.frame)+herizonSpace,2,huifuSize.width,huifuSize.height);
-
- _secondNameLabel.text = [NSString stringWithFormat:@"%@:",model.ReplyName];
- _secondNameLabel.textColor = UIColorHex(1F87DB);
- [ZYCTool setLabel:_secondNameLabel withSpace:10 withFont:[UIFont systemFontOfSize:17.f] setLineSpace:0 setTextSpace:2];
- CGSize secondNameSize = [_secondNameLabel sizeThatFits:CGSizeMake(kGXScreenWidth - 68 ,MAXFLOAT)];
-
- _secondNameLabel.frame = CGRectMake(CGRectGetMaxX(_huifuLabel.frame)+herizonSpace,2,secondNameSize.width, secondNameSize.height);
-
- _contentLabel.text = model.Content;
- [ZYCTool setLabel:_contentLabel withSpace:10 withFont:[UIFont systemFontOfSize:17.f] setLineSpace:0 setTextSpace:2];
- CGSize contentSize = [_contentLabel sizeThatFits:CGSizeMake(kGXScreenWidth - leftMargin -rightMargin ,MAXFLOAT)];
- _contentLabel.frame = CGRectMake(CGRectGetMaxX(_secondNameLabel.frame)+ herizonSpace,2,contentSize.width, contentSize.height);
-
- _timeLabel.text = model.time;
- _timeLabel.font = [UIFont systemFontOfSize:16.f];
- CGSize timeSize = [_timeLabel sizeThatFits:CGSizeMake(kGXScreenWidth - 68 - 21,MAXFLOAT)];
-
- _timeLabel.frame = CGRectMake(CGRectGetMaxX(_contentLabel.frame) + herizonSpace,2,timeSize.width, timeSize.height);
-
- if ([model.time isEqual: @"刚刚"]){
- _timeLabel.textColor = UIColorHex(E9382C);
- }
-
-
- // CGFloat width_o = kGXScreenWidth - leftMargin - rightMargin - nameSize.width - herizonSpace - huifuSize.width - herizonSpace - secondNameSize.width - herizonSpace - contentSize.width; // 剩余宽度
-
- // if (width_o == 0){
- // _
- //
- // }else if (width_o >= 0){
- //
- // }else{
- //
- // }
-
-
- }else{
- _nameLabel.text = [NSString stringWithFormat:@"%@:",model.Name];
- _nameLabel.textColor = UIColorHex(1F87DB);
- [ZYCTool setLabel:_nameLabel withSpace:10 withFont:[UIFont systemFontOfSize:17.f] setLineSpace:0 setTextSpace:2];
- CGSize nameSize = [_nameLabel sizeThatFits:CGSizeMake(kGXScreenWidth - leftMargin - rightMargin ,MAXFLOAT)];
- _nameLabel.frame = CGRectMake(leftMargin,0,nameSize.width, nameSize.height);
-
-
- _contentLabel.text = model.Content;
- [ZYCTool setLabel:_contentLabel withSpace:10 withFont:[UIFont systemFontOfSize:17.f] setLineSpace:0 setTextSpace:2];
- CGSize contentSize = [_contentLabel sizeThatFits:CGSizeMake(kGXScreenWidth - leftMargin -rightMargin ,MAXFLOAT)];
- _contentLabel.frame = CGRectMake(CGRectGetMaxX(_nameLabel.frame)+ herizonSpace,0,contentSize.width, contentSize.height);
-
- CGFloat width_o = kGXScreenWidth - leftMargin - rightMargin - nameSize.width - herizonSpace - contentSize.width - herizonSpace; // 剩余宽度
-
- _timeLabel.text = model.time;
- CGSize timeSize = [_timeLabel sizeThatFits:CGSizeMake(kGXScreenWidth - 68 - 21,MAXFLOAT)];
- if (width_o < timeSize.width ) {
- _timeLabel.frame = CGRectMake(leftMargin,CGRectGetMaxY(_contentLabel.frame)-6,timeSize.width, timeSize.height);
- }else{
- _timeLabel.frame = CGRectMake(CGRectGetMaxX(_contentLabel.frame) + herizonSpace,0,timeSize.width, timeSize.height);
- }
- }
-
- }
- - (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
- {
- self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
- if (self) {
- // Initialization code
- [self addSubview:self.nameLabel];
- [self addSubview:self.secondNameLabel];
- [self addSubview:self.huifuLabel];
- [self addSubview:self.timeLabel];
- [self addSubview:self.contentLabel];
- }
- return self;
- }
- - (void)setSelected:(BOOL)selected animated:(BOOL)animated {
- [super setSelected:selected animated:animated];
- // Configure the view for the selected state
- }
- - (UILabel *)nameLabel {
- if (!_nameLabel) {
- _nameLabel = [UILabel new];
- _nameLabel.font = [UIFont systemFontOfSize:15.f];
- _nameLabel.textColor = k6;
- _nameLabel.text = @"占位";
- }
- return _nameLabel;
- }
- - (UILabel *)secondNameLabel{
- if(!_secondNameLabel){
- _secondNameLabel = [UILabel new];
- _secondNameLabel.font = [UIFont systemFontOfSize:15.f];
- _secondNameLabel.textColor = k6;
- _secondNameLabel.text = @"占位";
- }
- return _secondNameLabel;
- }
- - (UILabel *)timeLabel {
- if (!_timeLabel) {
- _timeLabel = [UILabel new];
- _timeLabel.font = [UIFont systemFontOfSize:12.f];
- _timeLabel.textColor = k9;
- _timeLabel.text = @"占位";
- }
- return _timeLabel;
- }
- - (UILabel *)contentLabel {
- if (!_contentLabel) {
- _contentLabel = [UILabel new];
- _contentLabel.numberOfLines = 0;
- _contentLabel.font = [UIFont systemFontOfSize:15.f];
- _contentLabel.textColor = k6;
- _contentLabel.text = @"占位";
- }
- return _contentLabel;
- }
- - (UILabel *)huifuLabel{
- if(!_huifuLabel){
- _huifuLabel = [[UILabel alloc]init];
- _huifuLabel.font = [UIFont systemFontOfSize:15.f];
- _huifuLabel.textColor = k9;
- _huifuLabel.text = @"占位";
- }
- return _huifuLabel;
- }
- @end
|