ArticleTableViewCell.m
2.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
//
// 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