forked from coding/Coding-iOS
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProjectFolderListCell.m
More file actions
executable file
·60 lines (54 loc) · 2.2 KB
/
ProjectFolderListCell.m
File metadata and controls
executable file
·60 lines (54 loc) · 2.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
//
// ProjectFolderListCell.m
// Coding_iOS
//
// Created by 王 原闯 on 14/10/29.
// Copyright (c) 2014年 Coding. All rights reserved.
//
#define kProjectFolderListCell_IconWidth 45.0
#define kProjectFolderListCell_LeftPading (kPaddingLeftWidth +kProjectFolderListCell_IconWidth +20.0)
#import "ProjectFolderListCell.h"
@interface ProjectFolderListCell ()
@property (strong, nonatomic) UIImageView *iconView;
@property (strong, nonatomic) UILabel *nameLabel;
@end
@implementation ProjectFolderListCell
- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
if (self) {
self.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
self.backgroundColor = [UIColor clearColor];
// Initialization code
if (!_iconView) {
_iconView = [[UIImageView alloc] initWithFrame:CGRectMake(kPaddingLeftWidth, ([ProjectFolderListCell cellHeight] - kProjectFolderListCell_IconWidth)/2, kProjectFolderListCell_IconWidth, kProjectFolderListCell_IconWidth)];
[self.contentView addSubview:_iconView];
}
if (!_nameLabel) {
_nameLabel = [[UILabel alloc] initWithFrame:CGRectMake(kProjectFolderListCell_LeftPading, ([ProjectFolderListCell cellHeight] - 30)/2, (kScreen_Width - kProjectFolderListCell_LeftPading - 30), 30)];
_nameLabel.textColor = [UIColor colorWithHexString:@"0x222222"];
_nameLabel.font = [UIFont systemFontOfSize:16];
[self.contentView addSubview:_nameLabel];
}
self.useToMove = NO;
}
return self;
}
- (void)layoutSubviews{
[super layoutSubviews];
if (!_folder) {
return;
}
if ([_folder isDefaultFolder]) {
_iconView.image = [UIImage imageNamed:@"icon_file_folder_default"];
}else{
_iconView.image = [UIImage imageNamed:@"icon_file_folder_normal"];
}
_nameLabel.text = !_useToMove?
[NSString stringWithFormat:@"%@(%ld)", _folder.name, (long)(_folder.fileCountIncludeSub)]
:[NSString stringWithFormat:@"%@(%ld)", _folder.name, (long)_folder.sub_folders.count];
}
+ (CGFloat)cellHeight{
return 75.0;
}
@end