zjf
2023-03-06 392b76515f40376b6d36f40a114850ef63650384
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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
//
//  PBExamineSearchController.m
//  IphoneBIMe
//
//  Created by zjf on 2018/11/28.
//  Copyright © 2018 ProBIM. All rights reserved.
//
 
#import "PBExamineSearchController.h"
 
@interface PBExamineSearchController ()<UISearchBarDelegate>
@property (nonatomic, strong) UISearchBar *searchBar;
@property (nonatomic, weak) UIButton *cancelBtn;
@end
 
@implementation PBExamineSearchController
- (void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];
    [self.navigationController setNavigationBarHidden:YES animated:animated];
    [UIApplication sharedApplication].statusBarStyle = UIStatusBarStyleDefault;
}
- (void)viewWillDisappear:(BOOL)animated {
    [self.navigationController setNavigationBarHidden:NO animated:animated];
}
- (void)viewDidLoad {
    [super viewDidLoad];
    [self setupNav];
}
- (void)setupNav {
    self.view.backgroundColor = [UIColor whiteColor];
    UIView *topV = [[UIView alloc] init];
    topV.backgroundColor = [UIColor whiteColor];
    [self.view addSubview:topV];
 
    [self.navigationController.navigationBar setBackgroundImage:[UIImage imageNamed:@"whileNav"] forBarMetrics:UIBarMetricsDefault];
    self.searchBar = [[UISearchBar alloc] init];
    self.searchBar.placeholder = @"请输入任务名称";
    self.searchBar.delegate = self;
    self.searchBar.returnKeyType = UIReturnKeySearch;
    self.searchBar.searchBarStyle = UISearchBarStyleMinimal;
    [topV addSubview:self.searchBar];
 
    [self.searchBar setShowsCancelButton:YES];
    UIButton *cancelBtn = [self.searchBar valueForKey:@"cancelButton"];
    self.cancelBtn = cancelBtn;
    
    UIView *linV = [[UIView alloc] init];
    linV.backgroundColor = PBColor(244, 245, 246);
    [topV addSubview:linV];
    CGFloat topH = 64;
    CGFloat searchTop = 23.f;
    if (IS_IPHONE_X) {
        topH = 64 + 24;
        searchTop = 23 + 24;
    }
    [topV mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.left.right.equalTo(self.view);
        make.height.equalTo(@(topH));
    }];
    [self.searchBar mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(topV).offset(searchTop);
        make.left.equalTo(topV).offset(20);
        make.right.equalTo(topV).offset(-20);
        make.height.equalTo(@40);
    }];
    [linV mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.bottom.equalTo(topV);
        make.height.equalTo(@1);
    }];
    [self.tableView mas_remakeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.view).offset(topH);
        make.left.right.bottom.equalTo(self.view);
    }];
    self.tableView.bounces = NO;
}
 
- (void)cancelAction {
    [self.searchBar resignFirstResponder];
    [self dismissViewControllerAnimated:YES completion:nil];
}
#pragma mark - UISearchBarDelegate
- (void)searchBarCancelButtonClicked:(UISearchBar*)searchBar {
    [self.searchBar resignFirstResponder];
    [self.navigationController popViewControllerAnimated:YES];
}
- (void)searchBarSearchButtonClicked:(UISearchBar *)searchBar {
    NSString *search = [searchBar.text stringByReplacingOccurrencesOfString:@" " withString:@""];
    if ([search isEqualToString:@""]){
        return;
    }
    [self.searchBar resignFirstResponder];
    self.searchText = searchBar.text;
    [self.tableView.mj_header beginRefreshing];
}
 
//- (void)loadIssueListWithTitle:(NSString *)title {
//    if ([title isEqualToString:@""]) {
//        self.examineArrM = nil;
//        [self.tableView reloadData];
//        return;
//    }
//    self.searchText = title;
//    [self.tableView.mj_header beginRefreshing];
//}
 
//- (UIButton *)maskBtn {
//    if (_maskBtn == nil) {
//        _maskBtn = [[UIButton alloc] initWithFrame:self.view.bounds];
//        _maskBtn.backgroundColor = [UIColor colorWithWhite:0 alpha:0.2];
//        [_maskBtn addTarget:self action:@selector(cancelMaskBtn) forControlEvents:UIControlEventTouchUpInside];
//    }
//    return _maskBtn;
//}
- (void)cancelMaskBtn {
    [self.searchBar resignFirstResponder];
}
/*
#pragma mark - Navigation
 
// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/
 
@end