NewsVideoTableViewCell.m 2.67 KB
//
//  NewsVideoTableViewCell.m
//  SCIOLiveCN
//
//  Created by huayu on 16/4/18.
//  Copyright © 2016年 huayu. All rights reserved.
//

#import "NewsVideoTableViewCell.h"

@implementation NewsVideoTableViewCell
- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.backgroundColor = HEXCOLOR(0xeaeded);
        _backGroundView = [[UIView alloc] initWithFrame:CGRectMake(12, 6, MainScreenHeight - 24, cellItemWidth/2 + 66.0)];
        _backGroundView.backgroundColor = [UIColor whiteColor];
        [self addSubview:_backGroundView];
        
        _backImage = [[UIImageView alloc] initWithFrame:CGRectMake(12, 6, MainScreenHeight - 24, cellItemWidth/2)];
        _backImage.contentMode = UIViewContentModeScaleAspectFill;
        _backImage.layer.masksToBounds = YES;
        [self addSubview:_backImage];
        
        _playImage = [[UIImageView alloc] initWithFrame:CGRectMake(12 + (MainScreenHeight - 49)/2, 6 + (cellItemWidth/2 - 25)/2, 25, 25)];
        [self addSubview:_playImage];
        
        _titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(20, cellItemWidth/2 + 10, MainScreenHeight - 40, 40)];
        _titleLabel.numberOfLines = 2;
        _titleLabel.backgroundColor = [UIColor clearColor];
        _titleLabel.textColor = HEXCOLOR(0x333333);
        _titleLabel.font = [UIFont systemFontOfSize:16];
        [self addSubview:_titleLabel];
        
        _timeLabel = [[UILabel alloc] initWithFrame:CGRectMake(20, cellItemWidth/2 + 52, MainScreenHeight - 40, 16)];
        _timeLabel.backgroundColor = [UIColor clearColor];
        _timeLabel.textColor = HEXCOLOR(0x666666);
        _timeLabel.font = [UIFont systemFontOfSize:12];
        [self addSubview:_timeLabel];
        
        _tagsLabel = [[UILabel alloc] initWithFrame:CGRectMake(MainScreenHeight - 112, cellItemWidth/2 + 52, 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 = MainScreenHeight - frame.size.width - 22;
        frame.origin.y = cellItemWidth/2 + 49;
    }
    [_tagsLabel setFrame:frame];
}
@end