CNLiveIndicatorTableViewCell.m 3.89 KB
//
//  CNLiveIndicatorTableViewCell.m
//  CNLiveScioLive
//
//  Created by CNLive-zxw on 2018/9/18.
//  Copyright © 2018年 CNLive. All rights reserved.
//

#import "CNLiveIndicatorTableViewCell.h"
#import "CNLiveModel.h"

@interface CNLiveIndicatorTableViewCell()
@property (nonatomic, strong) UILabel *titleLabel;
@property (nonatomic, strong) UILabel *timeLabel;
@property (nonatomic, strong) UILabel *detailsLabel;
@property (nonatomic, strong) UIImageView *indicatorImage;

@end

@implementation CNLiveIndicatorTableViewCell

- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
//        self.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
        _titleLabel = [[UILabel alloc] init];
        _titleLabel.numberOfLines = 2;
        _titleLabel.lineBreakMode = NSLineBreakByTruncatingTail;
        _titleLabel.textColor = HEXCOLOR(0x333333);
        _titleLabel.font = [UIFont systemFontOfSize:16];
        [self addSubview:_titleLabel];
        
        _timeLabel = [[UILabel alloc] init];
        _timeLabel.numberOfLines = 1;
        _timeLabel.textColor = HEXCOLOR(0x333333);
        _timeLabel.font = [UIFont systemFontOfSize:14];
        [self addSubview:_timeLabel];
        
        _detailsLabel = [[UILabel alloc] init];
        _detailsLabel.numberOfLines = 1;
        _detailsLabel.textColor = HEXCOLOR(0x333333);
        _detailsLabel.font = [UIFont systemFontOfSize:12];
        [self addSubview:_detailsLabel];
    
        _indicatorImage = [[UIImageView alloc] init];
        _indicatorImage.contentMode = UIViewContentModeCenter;
        _indicatorImage.layer.masksToBounds = YES;
        _indicatorImage.image = [UIImage imageNamed:@"cnlive_my_next"];
        [self addSubview:_indicatorImage];
    }
    return self;
}
- (void)setModel:(CNLiveModel *)model{
    _model = model;
    _titleLabel.text = model.title;
    _timeLabel.text = model.liveStartDateTime;
    _detailsLabel.text = @"详情";

}
-(void)setType:(NSString *)type{
    _type = type;
    [self layoutSubviews];
}
- (void)layoutSubviews{
    if ([_type isEqualToString:@"查看发布会预告"]) {
        
        _titleLabel.text = _type;
        _titleLabel.font = [UIFont systemFontOfSize:14];

        [_titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.mas_left).with.offset(10);
            make.right.equalTo(self.mas_right).with.offset(-10-20);
            make.height.equalTo(self.mas_height);

        }];
        
    }else{
        [_detailsLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.mas_left).with.offset(10);
            make.right.equalTo(self.mas_right).with.offset(-10-20);
            make.bottom.equalTo(self.mas_bottom).with.offset(-10);
        }];
        
        [_timeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.mas_left).with.offset(10);
            make.right.equalTo(self.mas_right).with.offset(-10-20);
            make.bottom.equalTo(self->_detailsLabel.mas_top).with.offset(-5);
        }];
        
        [_titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.mas_left).with.offset(10);
            make.right.equalTo(self.mas_right).with.offset(-10-20);
            make.top.equalTo(self.mas_top).with.offset(10);
            
        }];
    }
    
    [_indicatorImage mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(self.mas_right).with.offset(-10);
        make.width.offset(12);
        make.height.equalTo(self.mas_height);

    }];
    
}
- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];
    
    // Configure the view for the selected state
}

@end