-
Notifications
You must be signed in to change notification settings - Fork 1.3k
/
Copy pathNProjectItemCell.m
105 lines (92 loc) · 3.46 KB
/
NProjectItemCell.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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
//
// NProjectItemCell.m
// Coding_iOS
//
// Created by Ease on 15/5/28.
// Copyright (c) 2015年 Coding. All rights reserved.
//
#import "NProjectItemCell.h"
@interface NProjectItemCell ()
@property (strong, nonatomic) UIImageView *imgView;
@property (strong, nonatomic) UILabel *titleLabel;
@property (strong, nonatomic) UILabel *rightLabel;
@end
@implementation NProjectItemCell
- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
if (self) {
// Initialization code
self.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
self.backgroundColor = kColorTableBG;
if (!_imgView) {
_imgView = [UIImageView new];
[self.contentView addSubview:_imgView];
[_imgView mas_makeConstraints:^(MASConstraintMaker *make) {
make.size.mas_equalTo(CGSizeMake(22, 22));
make.left.equalTo(self.contentView).offset(kPaddingLeftWidth);
make.centerY.equalTo(self.contentView);
}];
}
if (!_titleLabel) {
_titleLabel = [UILabel new];
_titleLabel.font = [UIFont systemFontOfSize:15];
_titleLabel.textColor = kColor222;
[self.contentView addSubview:_titleLabel];
[_titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.left.equalTo(_imgView.mas_right).offset(15);
make.right.equalTo(self.contentView).offset(-kPaddingLeftWidth);
make.centerY.height.equalTo(self.contentView);
}];
}
if (!_rightLabel) {
_rightLabel = [[UILabel alloc] initWithFrame:CGRectMake(CGRectGetMaxX(_titleLabel.frame), 7, kScreen_Width - CGRectGetMaxX(_titleLabel.frame) - 35, 30)];
_rightLabel.font = [UIFont systemFontOfSize:18];
_rightLabel.textColor = kColor999;
_rightLabel.textAlignment = NSTextAlignmentRight;
[self.rightLabel setHidden:YES];
[self.contentView addSubview:_rightLabel];
}
self.clipsToBounds = YES;
}
return self;
}
- (void)prepareForReuse{
[super prepareForReuse];
[self removeTip];
self.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
}
- (void)addTip:(NSString *)countStr{
self.accessoryType = UITableViewCellAccessoryNone;
CGFloat pointX = kScreen_Width - 25;
CGFloat pointY = [[self class] cellHeight]/2;
[self.contentView addBadgeTip:countStr withCenterPosition:CGPointMake(pointX, pointY)];
}
- (void)addTipIcon{
CGFloat pointX = kScreen_Width - 40;
CGFloat pointY = [[self class] cellHeight]/2;
[self.contentView addBadgeTip:kBadgeTipStr withCenterPosition:CGPointMake(pointX, pointY)];
}
- (void)addTipHeadIcon:(NSString *)IconString {
CGFloat pointX = kScreen_Width - 40;
CGFloat pointY = [[self class] cellHeight]/2;
[self.contentView addBadgeTip:IconString withCenterPosition:CGPointMake(pointX, pointY)];
}
- (void)removeTip{
[self.contentView removeBadgeTips];
}
- (void)setImageStr:(NSString *)imgStr andTitle:(NSString *)title{
self.imgView.image = [UIImage imageNamed:imgStr];
self.titleLabel.text = title;
}
- (void)setrightText:(NSString *)rightText {
[self.rightLabel setHidden:NO];
self.rightLabel.text = rightText;
}
- (void)setNorightText {
[self.rightLabel setHidden:YES];
}
+ (CGFloat)cellHeight{
return 50.0;
}
@end