forked from coding/Coding-iOS
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSkillCCell.m
More file actions
63 lines (55 loc) · 1.99 KB
/
Copy pathSkillCCell.m
File metadata and controls
63 lines (55 loc) · 1.99 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
//
// SkillCCell.m
// Coding_iOS
//
// Created by Easeeeeeeeee on 2017/12/25.
// Copyright © 2017年 Coding. All rights reserved.
//
#import "SkillCCell.h"
@interface SkillCCell ()
@property (strong, nonatomic) UILabel *contentLabel;
@property (strong, nonatomic) UIButton *deleteB;
@end
@implementation SkillCCell
- (void)setCurSkill:(CodingSkill *)curSkill{
_curSkill = curSkill;
if (!_curSkill) {
return;
}
if (!_contentLabel) {
self.contentView.backgroundColor = kColorBrandBlue;
self.contentView.layer.cornerRadius = 2.0;
self.layer.cornerRadius = 2.0;
_contentLabel = [UILabel labelWithFont:[UIFont systemFontOfSize:14] textColor:kColorWhite];
_contentLabel.minimumScaleFactor = 0.5;
_contentLabel.adjustsFontSizeToFitWidth = YES;
[self.contentView addSubview:_contentLabel];
_deleteB = [UIButton new];
[_deleteB setImage:[UIImage imageNamed:@"skill_delete"] forState:UIControlStateNormal];
__weak typeof(self) weakSelf = self;
[_deleteB bk_addEventHandler:^(id sender) {
if (weakSelf.deleteBlock) {
weakSelf.deleteBlock(weakSelf.curSkill);
}
} forControlEvents:UIControlEventTouchUpInside];
[self.contentView addSubview:_deleteB];
[_deleteB mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.bottom.right.equalTo(self.contentView);
make.width.mas_equalTo(30);
}];
[_contentLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.centerY.equalTo(self.contentView);
make.left.equalTo(self.contentView).offset(10);
make.right.equalTo(_deleteB.mas_left).offset(-5);
}];
}
_contentLabel.text = _curSkill.skill_str;
}
+ (CGSize)ccellSizeWithObj:(id)obj{
CGSize ccellSize = CGSizeZero;
if ([obj isKindOfClass:[CodingSkill class]]) {
ccellSize = CGSizeMake((kScreen_Width - 30 - 10)/ 2, 30);
}
return ccellSize;
}
@end