self.noteSearchResultVC = [[NoteSearchResultViewController alloc]init];
self.noteSearchResultVC.mainSearchController = self;
self.noteSearchResultVC.noteSearchResultDelegate = self;
self.searchVC = [[UISearchController alloc]initWithSearchResultsController:self.noteSearchResultVC];
self.searchVC.searchBar.placeholder = @"搜索记事";
//改变搜索框外部框的颜色(需要隐藏background才能显示背景色)
self.searchVC.searchBar.backgroundImage = [[UIImage alloc]init];
[self.searchVC.searchBar sizeToFit];
//用textfiled代替搜索框
UITextField *searchField=[self.searchVC.searchBar valueForKey:@"_searchField"];
searchField.backgroundColor = UIColorFromRGB(227, 227, 227);
//placeholderLabel.textColor的颜色
[searchField setValue:UIColorFromRGB(122, 122, 122) forKeyPath:@"_placeholderLabel.textColor"];
self.searchVC.searchBar.layer.borderColor = [UIColor lightGrayColor].CGColor;
self.searchVC.searchBar.layer.borderWidth = 0.5;
self.searchVC.hidesNavigationBarDuringPresentation = YES;
self.searchVC.searchResultsUpdater = self;
self.definesPresentationContext = YES;
self.searchVC.searchBar.delegate = self;
修改UISearchBar背景颜色(内外框)
最新推荐文章于 2024-07-06 22:22:46 发布