PYSearch
GitHub地址:https://github.com/iphone5solo/PYSearch
項目作者:CoderKo1o
- An elegant search controller for iOS.
- iOS 中一款優雅的搜索控制器。
Features
- 支持多種熱門搜索風格
- 支持多種搜索歷史風格
- 支持搜索建議
- 支持搜索歷史(記錄)緩存
- 支持使用delegate 或者 block 完成搜索時的回調
- 支持CocoaPods
Requirements
- iOS 7.0 or later
- Xcode 8.0 or later
Contents
Getting Started
Usage
效果圖
支持哪些風格
熱門搜索風格
搜索歷史風格
如何使用PYSearch
- 使用CocoaPods:
pod "PYSearch"
- 導入主頭文件
#import <PYSearch.h>
- 手動導入:
- 將
PYSearch
文件夾中的所有文件拽入項目中 - 導入主頭文件
#import "PYSearch.h"
- 將
具體使用(詳情見示例程序PYSearchExample)
// 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];
自定義PYSearch
通過設置searchViewContoller的對象屬性值即可修改
- 設置熱門搜索風格(默認爲PYHotSearchStyleNormalTag)
// 設置熱門搜索爲彩色標籤風格
searchViewController.hotSearchStyle = PYHotSearchStyleColorfulTag;
- 設置搜索歷史風格(默認爲PYSearchHistoryStyleCell)
// 設置搜索歷史爲帶邊框標籤風格
searchViewController.searchHistoryStyle = PYSearchHistoryStyleBorderTag;
- 隱藏搜索建議(默認爲:NO)
// 隱藏搜索建議
searchViewController.searchSuggestionHidden = YES;
期待
- 如果您在使用過程中有任何問題,歡迎issue me! 很樂意爲您解答任何相關問題!
- 與其給我點star,不如向我狠狠地拋來一個BUG!
- 如果想要參與這個項目的維護或者有好的設計風格,歡迎pull request!
- 如果您想要更多的接口來自定義或者建議/意見,歡迎issue me!我會根據大家的需求提供更多的接口!
Licenses
All source code is licensed under the MIT License.