GitHub地址:https://github.com/iphone5solo/PYSearchgit
項目做者:CoderKo1ogithub
PYSearch
PYSearchConst
PYSearchViewController
PYSearchSuggestionViewController
UIColor+PYExtension
UIView+PYExtension
![](http://oe1ml9cxe.bkt.clouddn.com/hotSearchStyle01.png ) ![](http://oe1ml9cxe.bkt.clouddn.com/hotSearchStyle02.png ) ![](http://oe1ml9cxe.bkt.clouddn.com/hotSearchStyle03.png ) ![](http://oe1ml9cxe.bkt.clouddn.com/hotSearchStyle04.png ) ![](http://oe1ml9cxe.bkt.clouddn.com/hotSearchStyle05.png ) ![](http://oe1ml9cxe.bkt.clouddn.com/hotSearchStyle06.png )編程
pod "PYSearch"
#import <PYSearch.h>
PYSearch
文件夾中的全部文件拽入項目中#import "PYSearch.h"
// 1. 建立熱門搜索數組 NSArray *hotSeaches = @[@"Java", @"Python", @"Objective-C", @"Swift", @"C", @"C++", @"PHP", @"C#", @"Perl", @"Go", @"JavaScript", @"R", @"Ruby", @"MATLAB"]; // 2. 建立搜索控制器 PYSearchViewController *searchViewController = [PYSearchViewController searchViewControllerWithHotSearches:hotSeaches searchBarPlaceholder:@"搜索編程語言" didSearchBlock:^(PYSearchViewController *searchViewController, UISearchBar *searchBar, NSString *searchText) { // 開始(點擊)搜索時執行如下代碼 // 如:跳轉到指定控制器 [searchViewController.navigationController pushViewController:[[UIViewController alloc] init] animated:YES]; }]; // 3. 跳轉到搜索控制器 UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:searchViewController]; [self presentViewController:nav animated:NO completion:nil];
// 設置熱門搜索爲彩色標籤風格 searchViewController.hotSearchStyle = PYHotSearchStyleColorfulTag;
// 設置搜索歷史爲帶邊框標籤風格 searchViewController.searchHistoryStyle = PYSearchHistoryStyleBorderTag;
// 設置搜索模式爲內嵌 searchViewController.searchResultShowMode = PYSearchResultShowModeEmbed;
// 隱藏搜索建議 searchViewController.searchSuggestionHidden = YES;
All source code is licensed under the MIT License.數組