// // DRTimeLineRecomCell.m // YouHuiProject // // Created by 小花 on 2019/1/7. // Copyright © 2019年 kuxuan. All rights reserved. // #import "DRTimeLineRecomCell.h" #import "CCCopyLabel.h" #import "DRTimeLineCommentView.h" #import "DRRecomPhotoView.h" @interface DRTimeLineRecomCell () @property (nonatomic, strong) UIImageView *iconView; @property (nonatomic, strong) UILabel *name; @property (nonatomic, strong) CCCopyLabel *title; //@property (nonatomic, strong) UILabel *localLabel; @property (nonatomic, strong) UILabel *timeLabel; @property (nonatomic, strong) UIButton *shareButton; //@property (nonatomic, strong) DRTimeLineCommentView *commentView; @property (nonatomic, strong) DRRecomPhotoView *PhotoContainerView; @end @implementation DRTimeLineRecomCell + (instancetype)cellWithTableView:(UITableView *)tableView { static NSString *cellID = nil; cellID = NSStringFromClass([self class]); DRTimeLineRecomCell *cell = [tableView dequeueReusableCellWithIdentifier:cellID]; if (!cell) { cell = [[DRTimeLineRecomCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellID]; cell.selectionStyle = UITableViewCellSelectionStyleNone; } return cell; } - (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier { self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]; if (self) { [self initSubViews]; } return self; } - (void)initSubViews { [self.contentView addSubview:self.iconView]; [self.contentView addSubview:self.name]; [self.contentView addSubview:self.title]; [self.contentView addSubview:self.PhotoContainerView]; // [self.contentView addSubview:self.localLabel]; [self.contentView addSubview:self.timeLabel]; // [self.contentView addSubview:self.shareButton]; // [self.contentView addSubview:self.commentView]; [self.iconView mas_makeConstraints:^(MASConstraintMaker *make) { make.left.mas_equalTo(10); make.top.mas_equalTo(14); make.width.height.mas_equalTo(42); }]; [self.name mas_makeConstraints:^(MASConstraintMaker *make) { make.left.mas_equalTo(self.iconView.mas_right).mas_offset(10); make.top.mas_equalTo(17); make.right.mas_equalTo(-10); }]; [self.title mas_makeConstraints:^(MASConstraintMaker *make) { make.top.mas_equalTo(self.name.mas_bottom).mas_offset(7); make.left.mas_equalTo(self.name); make.right.mas_equalTo(-10); }]; [self.PhotoContainerView mas_makeConstraints:^(MASConstraintMaker *make) { make.left.mas_equalTo(self.title.mas_left); make.top.mas_equalTo(self.title.mas_bottom).mas_offset(8); make.width.height.mas_equalTo(144); }]; // [self.localLabel mas_makeConstraints:^(MASConstraintMaker *make) { // make.left.mas_equalTo(self.title.mas_left); // make.right.mas_equalTo(-10); // make.top.mas_equalTo(self.PhotoContainerView.mas_bottom).mas_offset(8); // }]; [self.timeLabel mas_makeConstraints:^(MASConstraintMaker *make) { make.left.mas_equalTo(self.title); make.top.mas_equalTo(self.PhotoContainerView.mas_bottom).mas_offset(8); make.right.mas_equalTo(-10); }]; // [self.shareButton mas_makeConstraints:^(MASConstraintMaker *make) { // make.right.mas_equalTo(-10); // make.centerY.mas_equalTo(self.timeLabel.mas_centerY); // make.width.mas_equalTo(50); // make.height.mas_equalTo(20); // }]; // _commentView.sd_layout // .leftEqualToView(self.name) // .rightSpaceToView(self.contentView, 10) // .topSpaceToView(_timeLabel, 10); } - (void)shareClick { if (self.shareClickBlock) { self.shareClickBlock(); } } - (void)setModel:(DRTimeLineModel *)model { _model = model; [self.iconView sd_setFadeImageWithURL:[NSURL URLWithString:model.subscribe_img] placeholderImage:nil options:0 progress:nil completed:nil]; self.name.text = model.subscribe_title; self.title.text = model.show_content; [self.PhotoContainerView setPicPathStringsArray:@[model.img]]; self.timeLabel.text = model.pass_time; // self.localLabel.text = model.location; UIView *bottomView; bottomView = _timeLabel; // [self.commentView setupWithLikeItemsArray:model.shareUser contentText:model.show_comment]; // if (!model.shareUser.count && model.show_comment.length==0) { // bottomView = _timeLabel; // } else { // bottomView = _commentView; // } [self setupAutoHeightWithBottomView:bottomView bottomMargin:15]; } - (UIImageView *)iconView { if (!_iconView) { _iconView = [[UIImageView alloc] init]; _iconView.layer.cornerRadius = 21; _iconView.layer.masksToBounds = YES; _iconView.backgroundColor = [UIColor yhGrayColor]; } return _iconView; } - (UILabel *)name { if (!_name) { _name = [[UILabel alloc] init]; _name.font = [UIFont boldSystemFontOfSize:17]; _name.textColor = [UIColor YHColorWithHex:0x576B95]; } return _name; } - (UILabel *)title { if (!_title) { _title = [[CCCopyLabel alloc] init]; _title.font = [UIFont fontWithName:@"HelveticaNeue" size:17]; _title.textColor = [UIColor YHColorWithHex:0x222222]; _title.numberOfLines = 0; } return _title; } //- (UILabel *)localLabel { // if (!_localLabel) { // _localLabel = [[UILabel alloc] init]; // _localLabel.font = [UIFont systemFontOfSize:14]; // _localLabel.textColor = [UIColor YHColorWithHex:0x576B95]; // } // return _localLabel; //} - (UILabel *)timeLabel { if (!_timeLabel) { _timeLabel = [[UILabel alloc] init]; _timeLabel.font = [UIFont systemFontOfSize:14]; _timeLabel.textColor = [UIColor YHColorWithHex:0xB2B2B2]; } return _timeLabel; } - (UIButton *)shareButton { if (!_shareButton) { _shareButton = [UIButton buttonWithType:UIButtonTypeCustom]; [_shareButton setTitle:@"分享" forState:UIControlStateNormal]; _shareButton.layer.cornerRadius = 10; _shareButton.layer.borderColor = [UIColor YHColorWithHex:0x576B95].CGColor; _shareButton.layer.borderWidth = 1; [_shareButton setTitleColor:[UIColor YHColorWithHex:0x576B95] forState:UIControlStateNormal]; _shareButton.titleLabel.font = [UIFont systemFontOfSize:11]; [_shareButton addTarget:self action:@selector(shareClick) forControlEvents:UIControlEventTouchUpInside]; } return _shareButton; } //- (DRTimeLineCommentView *)commentView { // if (!_commentView) { // _commentView = [DRTimeLineCommentView new]; // } // return _commentView; //} - (DRRecomPhotoView *)PhotoContainerView { if (!_PhotoContainerView) { _PhotoContainerView = [[DRRecomPhotoView alloc] initWithFrame:CGRectMake(0, 0, 104, 104)]; } return _PhotoContainerView; } @end