forked from coding/Coding-iOS
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTagCCell.m
More file actions
executable file
·67 lines (58 loc) · 2.01 KB
/
Copy pathTagCCell.m
File metadata and controls
executable file
·67 lines (58 loc) · 2.01 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
//
// TagCCell.m
// Coding_iOS
//
// Created by 王 原闯 on 14-10-11.
// Copyright (c) 2014年 Coding. All rights reserved.
//
#define kTagCCell_Font [UIFont systemFontOfSize:14]
#define kTagCCell_Height 40.0
#define kTagCCell_Width ((kScreen_Width-36.0)/3)
#import "TagCCell.h"
@interface TagCCell ()
@property (strong, nonatomic) UILabel *contentLabel;
@end
@implementation TagCCell
- (void)setCurTag:(Tag *)curTag{
_curTag = curTag;
if (!_curTag) {
return;
}
if (!_contentLabel) {
self.contentView.layer.cornerRadius = 2.0;
self.layer.cornerRadius = 2.0;
_contentLabel = [[UILabel alloc] initWithFrame:CGRectMake(5, (kTagCCell_Height-20)/2, kTagCCell_Width, 20)];
_contentLabel.font = kTagCCell_Font;
_contentLabel.textAlignment = NSTextAlignmentCenter;
_contentLabel.minimumScaleFactor = 0.5;
_contentLabel.adjustsFontSizeToFitWidth = YES;
[self.contentView addSubview:_contentLabel];
}
_contentLabel.text = _curTag.name;
// [_contentLabel setLongString:_curTag.name withVariableWidth:kScreen_Width];
[_contentLabel setCenter:self.contentView.center];
}
- (void)setHasBeenSelected:(BOOL)hasBeenSelected{
_hasBeenSelected = hasBeenSelected;
if (_hasBeenSelected) {
self.backgroundColor = [UIColor colorWithHexString:@"0x3bbd79"];
_contentLabel.textColor = [UIColor whiteColor];
}else{
self.backgroundColor = kColorTableSectionBg;
_contentLabel.textColor = [UIColor blackColor];
}
}
- (void)setSelected:(BOOL)selected{
}
+ (CGSize)ccellSizeWithObj:(id)obj{
CGSize ccellSize = CGSizeZero;
if ([obj isKindOfClass:[Tag class]]) {
// Tag *curTag = (Tag *)obj;
// CGFloat strWidth = [curTag.name getWidthWithFont:kTagCCell_Font constrainedToSize:CGSizeMake(kScreen_Width, 20)]+10;
// strWidth = MAX(55, strWidth);
// CGFloat strWidth = (kScreen_Width-40)/3;
ccellSize = CGSizeMake(kTagCCell_Width, kTagCCell_Height);
}
return ccellSize;
}
@end