CNWitnessSearchCell.m
2.36 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
68
69
70
71
72
73
74
75
76
77
78
//
// CNWitnessSearchCell.m
// CNLiveVideoClassifyKit
//
// Created by CNLive on 2022/6/16.
//
#import "CNWitnessSearchCell.h"
@interface CNWitnessSearchCell()
@property (nonatomic, strong)UILabel *textLabel;
@property (nonatomic, strong)UIView *lineView;
@property (nonatomic, strong)UIButton *delectBtn;
@end
@implementation CNWitnessSearchCell
- (instancetype)initWithFrame:(CGRect)frame
{
if (self = [super initWithFrame:frame]) {
[self.contentView addSubview:self.textLabel];
[self.contentView addSubview:self.lineView];
[self.contentView addSubview:self.delectBtn];
[self.textLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.centerY.left.equalTo(self);
make.right.equalTo(self.delectBtn.mas_left);
}];
[self.lineView mas_makeConstraints:^(MASConstraintMaker *make) {
make.right.bottom.left.equalTo(self);
make.height.mas_equalTo(0.5);
}];
[self.delectBtn mas_makeConstraints:^(MASConstraintMaker *make) {
make.right.centerY.equalTo(self);
make.width.height.mas_equalTo(11.5);
}];
}
return self;
}
- (void)deleteBtnClick{
if (self.deleteBlock) {
self.deleteBlock(self.textLabel.text);
}
}
- (void)setString:(NSString *)str section:(NSInteger)section{
self.textLabel.text = str;
if (section == 0) {
self.lineView.hidden = NO;
self.delectBtn.hidden = NO;
}else{
self.lineView.hidden = YES;
self.delectBtn.hidden = YES;
}
}
#pragma mark - Getting
- (UILabel *)textLabel
{
if (!_textLabel) {
_textLabel = [[UILabel alloc] init];
_textLabel.font = UIFontMake(14);
_textLabel.textColor = UIColorHex(#333333);
_textLabel.textAlignment = NSTextAlignmentLeft;
}
return _textLabel;
}
- (UIView *)lineView{
if (!_lineView) {
_lineView = [[UIView alloc] init];
_lineView.backgroundColor = UIColorHex(#F2F2F2);
}
return _lineView;
}
- (UIButton *)delectBtn{
if (!_delectBtn) {
_delectBtn = [UIButton buttonWithType:UIButtonTypeCustom];
[_delectBtn setImage:[UIImage loadBundleImage:@"witness_history_delete"] forState:UIControlStateNormal];
[_delectBtn addTarget:self action:@selector(deleteBtnClick) forControlEvents:UIControlEventTouchUpInside];
}
return _delectBtn;
}
@end