developer
2023-05-20 c1ffd99c4b60066774eb2c97b31e4aaa014e7f51
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
//
//  SearchRecordHeaderView.m
//  BuWanVideo2.0
//
//  Created by Aeline on 2021/5/30.
//  Copyright © 2021 com.yeshi.buwansheque.ios. All rights reserved.
//
 
#import "SearchRecordHeaderView.h"
 
@interface SearchRecordHeaderView ()
@property (nonatomic, nullable, strong) UIButton *buttonDelete;
@property (nonatomic, nullable, strong) UILabel *labelTitle;
@end
 
@implementation SearchRecordHeaderView
 
- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
       
        [self setupViewConfig];
    }
    return self;
}
 
- (void)setupViewConfig {
 
    [self addSubview:self.labelTitle];
    [self addSubview:self.buttonDelete];
    self.labelTitle.sd_layout.leftSpaceToView(self, 12).topSpaceToView(self, 20).widthIs(100).heightIs(16);
    
    self.buttonDelete.sd_layout.rightSpaceToView(self, 10).centerYEqualToView(self.labelTitle).widthIs(30).heightIs(30);
}
 
- (void)toucnDeleteRecord {
    if (_delegate && [_delegate respondsToSelector:@selector(deleteRecordEvent)]) {
        [_delegate deleteRecordEvent];
    }
}
 
- (UILabel *)labelTitle {
    if (!_labelTitle) {
        _labelTitle = [[UILabel alloc] init];
        _labelTitle.text = @"搜索记录";
        _labelTitle.textColor = UICOLOR_FROM_RGB(0x333333, 1);
        _labelTitle.font = [UIFont boldSystemFontOfSize:16];
        _labelTitle.textAlignment = NSTextAlignmentLeft;
    }
    return _labelTitle;
}
 
- (UIButton *)buttonDelete {
    if (!_buttonDelete) {
        _buttonDelete = [UIButton buttonWithType:UIButtonTypeCustom];
        [_buttonDelete setImage:[UIImage imageNamed:@"search_delete"] forState:UIControlStateNormal];
        [_buttonDelete addTarget:self action:@selector(toucnDeleteRecord) forControlEvents:UIControlEventTouchUpInside];
    }
    return _buttonDelete;
}
@end