-
Notifications
You must be signed in to change notification settings - Fork 1.3k
/
Copy pathForkTreeCell.m
78 lines (70 loc) · 2.89 KB
/
ForkTreeCell.m
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
72
73
74
75
76
77
78
//
// ForkTreeCell.m
// Coding_iOS
//
// Created by Ease on 15/9/19.
// Copyright (c) 2015年 Coding. All rights reserved.
//
#define kForkTreeCell_IconWidth 40.0
#import "ForkTreeCell.h"
@interface ForkTreeCell ()
@property (nonatomic, strong) UIImageView *forkerIconView;
@property (nonatomic, strong) UILabel *projectTitleLabel;
@property (nonatomic, strong) UILabel *forkInfoLabel;
@end
@implementation ForkTreeCell
- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
if (self) {
// Initialization code
self.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
if (!_forkerIconView) {
_forkerIconView = [YLImageView new];
_forkerIconView.layer.masksToBounds = YES;
_forkerIconView.layer.cornerRadius = kForkTreeCell_IconWidth/2;
[self.contentView addSubview:_forkerIconView];
}
if (!_projectTitleLabel) {
_projectTitleLabel = [UILabel new];
_projectTitleLabel.textColor = kColor222;
_projectTitleLabel.font = [UIFont systemFontOfSize:15];
[self.contentView addSubview:_projectTitleLabel];
}
if (!_forkInfoLabel) {
_forkInfoLabel = [UILabel new];
_forkInfoLabel.textColor = kColor999;
_forkInfoLabel.font = [UIFont systemFontOfSize:12];
[self.contentView addSubview:_forkInfoLabel];
}
[_forkerIconView mas_makeConstraints:^(MASConstraintMaker *make) {
make.centerY.equalTo(self.contentView);
make.left.equalTo(self.contentView.mas_left).offset(kPaddingLeftWidth);
make.size.mas_equalTo(CGSizeMake(kForkTreeCell_IconWidth, kForkTreeCell_IconWidth));
}];
[_projectTitleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.equalTo(self.contentView).offset(5);
make.height.mas_equalTo(20);
make.left.equalTo(self.forkerIconView.mas_right).offset(20);
make.right.lessThanOrEqualTo(self.contentView).offset(0);
}];
[_forkInfoLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.right.height.equalTo(self.projectTitleLabel);
make.top.equalTo(self.projectTitleLabel.mas_bottom).offset(5);
}];
}
return self;
}
- (void)setProject:(Project *)project{
_project = project;
if (!_project) {
return;
}
[_forkerIconView sd_setImageWithURL:[_project.owner.avatar urlImageWithCodePathResize:2*kForkTreeCell_IconWidth crop:YES] placeholderImage:kPlaceholderCodingSquareWidth(55.0)];
_projectTitleLabel.text = _project.path;
_forkInfoLabel.text = [NSString stringWithFormat:@"%@ Fork于 %@", _project.owner.name, [project.created_at stringDisplay_HHmm]];
}
+ (CGFloat)cellHeight{
return 60.0;
}
@end