forked from coding/Coding-iOS
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProjectDescriptionCell.m
More file actions
63 lines (55 loc) · 2.15 KB
/
ProjectDescriptionCell.m
File metadata and controls
63 lines (55 loc) · 2.15 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
//
// ProjectDescriptionCell.m
// Coding_iOS
//
// Created by Ease on 15/3/12.
// Copyright (c) 2015年 Coding. All rights reserved.
//
#define kProjectDescriptionCell_Font [UIFont systemFontOfSize:15]
#define kProjectDescriptionCell_ContentWidth (kScreen_Width - kPaddingLeftWidth*2)
#import "ProjectDescriptionCell.h"
#import "EaseGitButton.h"
@interface ProjectDescriptionCell ()
@property (strong, nonatomic) UILabel *proDesL;
@end
@implementation ProjectDescriptionCell
- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
if (self) {
// Initialization code
self.selectionStyle = UITableViewCellSelectionStyleNone;
self.backgroundColor = kColorTableBG;
if (!_proDesL) {
_proDesL = [[UILabel alloc] init];
_proDesL.numberOfLines = 0;
_proDesL.font = kProjectDescriptionCell_Font;
_proDesL.textColor = [UIColor colorWithHexString:@"0x222222"];
[self.contentView addSubview:_proDesL];
}
}
return self;
}
- (void)setDescriptionStr:(NSString *)descriptionStr{
if (descriptionStr.length > 0) {
_proDesL.text = descriptionStr;
}else{
_proDesL.text = @"未填写";
}
}
- (void)layoutSubviews{
[super layoutSubviews];
CGFloat desHeight = [_proDesL.text getSizeWithFont:kProjectDescriptionCell_Font constrainedToSize:CGSizeMake(kProjectDescriptionCell_ContentWidth, CGFLOAT_MAX)].height;
[_proDesL setFrame:CGRectMake(kPaddingLeftWidth, 15, kProjectDescriptionCell_ContentWidth, desHeight)];
}
+ (CGFloat)cellHeightWithObj:(id)obj{
CGFloat cellHeight = 0;
if ([obj isKindOfClass:[Project class]]) {
Project *curProject = (Project *)obj;
NSString *descriptionStr = curProject.description_mine.length > 0? curProject.description_mine: @"未填写";
CGFloat desHeight = [descriptionStr getSizeWithFont:kProjectDescriptionCell_Font constrainedToSize:CGSizeMake(kProjectDescriptionCell_ContentWidth, CGFLOAT_MAX)].height;
cellHeight += desHeight + 2*15;
}
return cellHeight;
}
@end