美文网首页iOS CollectioniOS 控件封装别人的iOS精华
一款综合(QQ 音乐、微信、美团、优酷、虎牙直播等多款 app)

一款综合(QQ 音乐、微信、美团、优酷、虎牙直播等多款 app)

作者: CoderKo1o | 来源:发表于2016-10-26 10:32 被阅读2202次

PYSearch

GitHub地址:https://github.com/iphone5solo/PYSearch
项目作者:CoderKo1o

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

Features

  • 支持多种热门搜索风格
  • 支持多种搜索历史风格
  • 支持多种搜索结果显示模式
  • 支持搜索建议
  • 支持搜索历史(记录)缓存
  • 支持使用delegate 或者 block 完成搜索时的回调
  • 支持CocoaPods
  • 支持iPhone & iPad及其横竖屏适配

Requirements

  • iOS 7.0 or later
  • Xcode 7.0 or later

Architecture

Main

  • PYSearch
  • PYSearchConst
  • PYSearchViewController
  • PYSearchSuggestionViewController

Category

  • UIColor+PYSearchExtension
  • UIView+PYSearchExtension
  • NSBundle+PYSearchExtension

Contents

<a id="效果图"></a>效果图

(img)
(img)
(img)
(img)
(img)

<a id="如何使用PYSearch"></a>如何使用PYSearch

  • 使用CocoaPods:
    • pod "PYSearch"
    • 导入主头文件#import <PYSearch.h>
  • 手动导入:
    • PYSearch文件夹中的所有文件拽入项目中
    • 导入主头文件#import "PYSearch.h"

<a id="具体使用(详情见示例程序PYSearchExample)"></a>具体使用(详情见示例程序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];

<a id="自定义PYSearch"></a>自定义PYSearch

通过设置searchViewContoller的对象属性值即可修改

  • 设置热门搜索风格(默认为PYHotSearchStyleNormalTag)
    // 设置热门搜索为彩色标签风格
    searchViewController.hotSearchStyle = PYHotSearchStyleColorfulTag;
  • 设置搜索历史风格(默认为PYSearchHistoryStyleCell)
    // 设置搜索历史为带边框标签风格
    searchViewController.searchHistoryStyle = PYSearchHistoryStyleBorderTag;
  • 设置搜索结果显示模式(默认为PYSearchResultShowModePush)
    // 设置搜索模式为内嵌
    searchViewController.searchResultShowMode = PYSearchResultShowModeEmbed;
  • 隐藏搜索建议(默认为:NO)
    // 隐藏搜索建议
    searchViewController.searchSuggestionHidden = YES;

<a id="期待"></a>期待

  • 如果您在使用过程中有任何问题,欢迎issue me! 很乐意为您解答任何相关问题!
  • 与其给我点star,不如向我狠狠地抛来一个BUG!
  • 如果想要参与这个项目的维护或者有好的设计风格,欢迎pull request!
  • 如果您想要更多的接口来自定义或者建议/意见,欢迎issue me!我会根据大家的需求提供更多的接口!
  • 如果您在使用中觉得略有不适,欢迎联系我QQ:499491531,希望一起完善此项目,让它变成更强大,能够满足大多数用户的需求!

Licenses

All source code is licensed under the MIT License.

相关文章

网友评论

  • panv587:PYSearchResultShowModeEmbed模式 搜索结果怎么展示
  • Locaus_Joe:请问那个 “设置搜索结果显示模式”设置不了呢,请指教,谢谢
  • ElliotYamin:搜索界面怎样刷新啊
  • 56da53701d80:prefect
  • Mr小猪:就是热门搜索和搜索历史能设置个参数上下调换位置就完美了
    CoderKo1o:现在已经支持了,还支持了iPad,和横竖屏适配了!
  • 恋熙:你好 我下载了一份运行 但是不会弹出键盘呀
  • 假城:棒棒的 拉进项目试一哈 :blush:
    CoderKo1o:@假城 觉得哪使用时不够方面,欢迎反馈! :blush:
  • 云逸枫林:不错,可以把搜索框改成圆角的更美观
    云逸枫林:@CoderKo1o 我也是从这里看到的:
    http://www.jianshu.com/p/6a14db9282df
    云逸枫林:@CoderKo1o 看看这样的效果还不错啊
    http://upload-images.jianshu.io/upload_images/227290-1b743ccf76baec7f.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240
    CoderKo1o:@云逸枫林 谢谢反馈。可以根据个人喜好设置 :smile:

本文标题:一款综合(QQ 音乐、微信、美团、优酷、虎牙直播等多款 app)

本文链接:https://www.haomeiwen.com/subject/ouhkuttx.html