CNMyTableViewCell.m
2 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
59
60
61
62
63
64
65
66
67
68
69
70
71
//
// CNMyTableViewCell.m
// CNLiveScioLive
//
// Created by CNLive-zxw on 2018/9/18.
// Copyright © 2018年 CNLive. All rights reserved.
//
#import "CNMyTableViewCell.h"
@interface CNMyTableViewCell()
@property (nonatomic, strong) UIImageView *rightImage;
@property (nonatomic, strong) UILabel *titleLabel;
@property (nonatomic, strong) UIImageView *leftImage;
@end
@implementation CNMyTableViewCell
static const NSInteger margin = 10;
- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
if (self) {
_rightImage = [[UIImageView alloc] init];
_rightImage.contentMode = UIViewContentModeCenter;
_rightImage.layer.masksToBounds = YES;
[self addSubview:_rightImage];
_titleLabel = [[UILabel alloc] init];
_titleLabel.numberOfLines = 1;
_titleLabel.textColor = HEXCOLOR(0x333333);
_titleLabel.font = [UIFont systemFontOfSize:15];
[self addSubview:_titleLabel];
_leftImage = [[UIImageView alloc] init];
_leftImage.contentMode = UIViewContentModeCenter;
_leftImage.image = [UIImage imageNamed:@"cnlive_my_next"];
[self addSubview:_leftImage];
}
return self;
}
- (void)setName:(NSString *)name{
_name = name;
_titleLabel.text = name;
}
-(void)setPic:(NSString *)pic{
_pic = pic;
_rightImage.image = [UIImage imageNamed:pic];
}
- (void)layoutSubviews{
_rightImage.frame = CGRectMake(margin, 0, 30, CGRectGetHeight(self.bounds));
_titleLabel.frame = CGRectMake(50, 0, 120, CGRectGetHeight(self.bounds));
_leftImage.frame = CGRectMake(CGRectGetMaxX(self.bounds)-margin-12, 0, 12, CGRectGetHeight(self.bounds));
}
- (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