ArticleTableViewCell.m 2.17 KB
//
//  ArticleTableViewCell.m
//  SCIOLiveCN
//
//  Created by huayu on 16/4/15.
//  Copyright © 2016年 huayu. All rights reserved.
//

#import "ArticleTableViewCell.h"

@implementation ArticleTableViewCell
- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        _backImage = [[UIImageView alloc] initWithFrame:CGRectMake(12, 6, 120, 74)];
        _backImage.contentMode = UIViewContentModeScaleAspectFill;
        _backImage.layer.masksToBounds = YES;
        [self addSubview:_backImage];
        
        _titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(142, 6, MainScreenWidth - 150, 55)];
        _titleLabel.numberOfLines = 2;
        _titleLabel.textColor = HEXCOLOR(0x333333);
        _titleLabel.font = [UIFont systemFontOfSize:16];
        _titleLabel.backgroundColor = [UIColor clearColor];
        [self addSubview:_titleLabel];
        
        _timeLabel = [[UILabel alloc] initWithFrame:CGRectMake(142, 63, MainScreenWidth - 154, 16)];
        _timeLabel.textColor = HEXCOLOR(0x666666);
        _timeLabel.font = [UIFont systemFontOfSize:12];
        _timeLabel.backgroundColor = [UIColor clearColor];
        [self addSubview:_timeLabel];
        
        _tagsLabel = [[UILabel alloc] initWithFrame:CGRectMake(MainScreenWidth - 112, 63, 0, 16)];
        _tagsLabel.textColor = HEXCOLOR(0xFFFFFF);
        _tagsLabel.font = [UIFont systemFontOfSize:12];
        _tagsLabel.textAlignment = NSTextAlignmentCenter;
        _tagsLabel.backgroundColor = HEXCOLOR(0x195AC9);
        _tagsLabel.layer.masksToBounds = YES;
        _tagsLabel.layer.cornerRadius = 4.0;
        [self addSubview:_tagsLabel];
    }
    return self;
}
- (void)reSetTagFrame {
    CGRect frame = CGRectZero;
    if ([_tagsLabel.text length] > 0) {
        [_tagsLabel sizeToFit];
        frame = _tagsLabel.frame;
        frame.size.width += 10;
        frame.size.height += 6;
        frame.origin.x = MainScreenWidth - frame.size.width - 22;
        frame.origin.y -= 3;
    }
    [_tagsLabel setFrame:frame];
    _tagsLabel.center = CGPointMake(_tagsLabel.center.x, _timeLabel.center.y);
}
@end