// // PBExamineSearchController.m // IphoneBIMe // // Created by zjf on 2018/11/28. // Copyright © 2018 ProBIM. All rights reserved. // #import "PBExamineSearchController.h" @interface PBExamineSearchController () @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