一款綜合(QQ 音樂、微信、美團、優酷、虎牙直播等多款 app)風格的搜索控制器

PYSearch

GitHub地址:github.com/iphone5solo…
項目做者:CoderKo1ogit

  • 🔍 An elegant search controller for iOS.
  • 🔍 iOS 中一款優雅的搜索控制器。

Features

  • 支持多種熱門搜索風格
  • 支持多種搜索歷史風格
  • 支持多種搜索結果顯示模式
  • 支持搜索建議
  • 支持搜索歷史(記錄)緩存
  • 支持使用delegate 或者 block 完成搜索時的回調
  • 支持CocoaPods

Requirements

  • iOS 7.0 or later
  • Xcode 7.0 or later

Architecture

Main

  • PYSearch
  • PYSearchConst
  • PYSearchViewController
  • PYSearchSuggestionViewController

Category

  • UIColor+PYExtension
  • UIView+PYExtension

Contents

效果圖

支持哪些風格

熱門搜索風格






搜索歷史風格





如何使用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)iphone

    // 設置搜索歷史爲帶邊框標籤風格
      searchViewController.searchHistoryStyle = PYSearchHistoryStyleBorderTag;複製代碼
  • 設置搜索結果顯示模式(默認爲PYSearchResultShowModePush)編程語言

    // 設置搜索模式爲內嵌
      searchViewController.searchResultShowMode = PYSearchResultShowModeEmbed;複製代碼
  • 隱藏搜索建議(默認爲:NO)ui

    // 隱藏搜索建議
      searchViewController.searchSuggestionHidden = YES;複製代碼

期待

  • 若是您在使用過程當中有任何問題,歡迎issue me! 很樂意爲您解答任何相關問題!
  • 與其給我點star,不如向我狠狠地拋來一個BUG!
  • 若是想要參與這個項目的維護或者有好的設計風格,歡迎pull request!
  • 若是您想要更多的接口來自定義或者建議/意見,歡迎issue me!我會根據你們的需求提供更多的接口!
  • 若是您在使用中以爲略有不適,歡迎聯繫我QQ:499491531,但願一塊兒完善此項目,讓它變成更強大,可以知足大多數用戶的需求!

Licenses

All source code is licensed under the MIT License.spa

相關文章
相關標籤/搜索