GitHub地址:github.com/iphone5solo…
項目做者:CoderKo1ogit
PYSearch
PYSearchConst
PYSearchViewController
PYSearchSuggestionViewController
UIColor+PYExtension
UIView+PYExtension
Getting Startedgithub
Usage編程
期待數組
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];複製代碼
設置熱門搜索風格(默認爲PYHotSearchStyleNormalTag)緩存
// 設置熱門搜索爲彩色標籤風格
searchViewController.hotSearchStyle = PYHotSearchStyleColorfulTag;複製代碼
設置搜索歷史風格(默認爲PYSearchHistoryStyleCell)iphone
// 設置搜索歷史爲帶邊框標籤風格
searchViewController.searchHistoryStyle = PYSearchHistoryStyleBorderTag;複製代碼
設置搜索結果顯示模式(默認爲PYSearchResultShowModePush)編程語言
// 設置搜索模式爲內嵌
searchViewController.searchResultShowMode = PYSearchResultShowModeEmbed;複製代碼
隱藏搜索建議(默認爲:NO)ui
// 隱藏搜索建議
searchViewController.searchSuggestionHidden = YES;複製代碼
All source code is licensed under the MIT License.spa