CNMyAnnouncementsTableViewCell.m 2.82 KB
//
//  CNMyAnnouncementsTableViewCell.m
//  CNLiveScioLive
//
//  Created by CNLive-zxw on 2018/9/20.
//  Copyright © 2018年 CNLive. All rights reserved.
//

#import "CNMyAnnouncementsTableViewCell.h"
#import "CNMyAnnouncementsModel.h"

@interface CNMyAnnouncementsTableViewCell()
@property (nonatomic, strong) UILabel *titleLabel;
@property (nonatomic, strong) UILabel *timeLabel;
@property (nonatomic, strong) UIImageView *line;

@end

@implementation CNMyAnnouncementsTableViewCell
static NSInteger margin = 10;

- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.contentView.backgroundColor = [UIColor whiteColor];
        
        _titleLabel = [[UILabel alloc] init];
        _titleLabel.numberOfLines = 0;
        _titleLabel.lineBreakMode = NSLineBreakByTruncatingTail;
        _titleLabel.textColor = HEXCOLOR(0x333333);
        _titleLabel.font = [UIFont systemFontOfSize:15];
        [self.contentView addSubview:_titleLabel];
        
        _timeLabel = [[UILabel alloc] init];
        _timeLabel.numberOfLines = 1;
        _timeLabel.textColor = HEXCOLOR(0xbbbbbb);
        _timeLabel.font = [UIFont systemFontOfSize:12];
        [self.contentView addSubview:_timeLabel];
        
        _line = [[UIImageView alloc] init];
        _line.backgroundColor = Color_Line;
        [self.contentView addSubview:_line];
        
    }
    return self;
    
}
- (void)setModel:(CNMyAnnouncementsModel *)model{
    _model = model;
    _titleLabel.text = model.title;
    _timeLabel.text = model.publishDate;
    [self layoutSubviews];
    
}
- (void)layoutSubviews{
    
    [_titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.mas_left).with.offset(margin);
        make.right.equalTo(self.mas_right).with.offset(-margin);
        make.top.equalTo(self.mas_top).with.offset(margin);
//        make.bottom.equalTo(self.mas_bottom).with.offset(-5);
        
    }];
    
    [_timeLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.mas_left).with.offset(margin);
        make.right.equalTo(self.mas_right).with.offset(-margin);
        make.bottom.equalTo(self.mas_bottom).with.offset(-margin);

    }];
    
    [_line mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.mas_left).with.offset(0);
        make.right.equalTo(self.mas_right).with.offset(0);
        make.bottom.equalTo(self.mas_bottom).with.offset(-1);
        make.height.offset(Line_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