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

huhepei 8年前發布 | 8K 次閱讀 iOS開發 移動開發

PYSearch

  • :mag: An elegant search controller for iOS.

  • :mag: iOS 中一款優雅的搜索控制器。

Features

  • 支持多種熱門搜索風格

  • 支持多種搜索歷史風格

  • 支持搜索建議

  • 支持搜索歷史(記錄)緩存

  • 支持使用delegate 或者 block 完成搜索時的回調

  • 支持CocoaPods

Requirements

  • iOS 7.0 or later
  • Xcode 8.0 or later

Contents

  • Getting Started

    • Renderings【效果圖】
    • Styles 【支持哪些風格】
    </li>
  • Usage

    • How to use【如何使用PYSearch】
    • Details 【具體使用(詳情見示例程序PYSearchExample)】
    • Custom【自定義PYSearch】
    • </ul> </li>
    • 期待

    • </ul>

      效果圖

      支持哪些風格

      熱門搜索風格

      搜索歷史風格

      如何使用PYSearch

      • 使用CocoaPods:

        • pod "PYSearch"
        • 導入主頭文件 #import <PYSearch.h>
        </li>
      • 手動導入:

        • 將 PYSearch 文件夾中的所有文件拽入項目中
        • 導入主頭文件 #import "PYSearch.h"
        • </ul> </li> </ul>

          具體使用(詳情見示例程序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.

           

           

           

 本文由用戶 huhepei 自行上傳分享,僅供網友學習交流。所有權歸原作者,若您的權利被侵害,請聯系管理員。
 轉載本站原創文章,請注明出處,并保留原始鏈接、圖片水印。
 本站是一個以用戶分享為主的開源技術平臺,歡迎各類分享!