帮酷LOGO
  • 显示原文与译文双语对照的内容
The famous iOS search bar with auto completion feature implemented.

  • 源代码名称:ModernSearchBar
  • 源代码网址:http://www.github.com/PhilippeBoisney/ModernSearchBar
  • ModernSearchBar源代码文档
  • ModernSearchBar源代码下载
  • Git URL:
    git://www.github.com/PhilippeBoisney/ModernSearchBar.git
  • Git Clone代码到本地:
    git clone http://www.github.com/PhilippeBoisney/ModernSearchBar
  • Subversion代码到本地:
    $ svn co --depth empty http://www.github.com/PhilippeBoisney/ModernSearchBar
    Checked out revision 1.
    $ cd repo
    $ svn up trunk
  • PlatformLanguageLicense

    演示文稿

    这里搜索栏允许你在使用默认的iOS搜索栏查找某些东西时向用户提供建议词。 it !

    演示

    使用这个库有两种方法:

    • 一个带有简单字符串 array的字符串( array <字符串> )
    • 如果你想从url获取每一行的图像,则使用自定义对象( array <ModernSearchBarModel> )的array 。
    简单高级

    安装

    CocoaPods

    你可以使用 CocoaPods插件将它的添加到你的中,以安装 ModernSearchBar:

    pod 'ModernSearchBar'
    手动
    • 下载并删除项目中Pod文件夹中包含的所有 *.swift 文件。
    • 请不要忘记导入资产文件夹。
    • enjoy!

    用法

    1-- 配置 Storyboard ( 自定义类)

    2-- 配置 ViewController

    //Import lib on the top of ViewControllerimportModernSearchBar//Create an IBOutlet from your searchBar@IBOutletweakvar modernSearchBar: ModernSearchBar!//Extend your ViewController with 'ModernSearchBarDelegate'classViewController: UIViewController, ModernSearchBarDelegate//Implement the delegationself.modernSearchBar.delegateModernSearchBar = self//Set datas to fill the suggestionsView of the searchbar.//Two ways (you have to choose only one, you can't implement both obviously)// 1 - With an Array<String>var suggestionList = Array<String>()
    suggestionList.append("Onions")
    suggestionList.append("Celery")
    self.modernSearchBar.setDatas(datas: suggestionList)// 2 - With custom Array<ModernSearchBarModel>var suggestionListWithUrl = Array<ModernSearchBarModel>()
    suggestionListWithUrl.append(ModernSearchBarModel(title:"Alpha", url:"https://github.com/PhilippeBoisney/ModernSearchBar/raw/master/Examples%20Url/exampleA.png"))suggestionListWithUrl.append(ModernSearchBarModel(title:"Bravo", url:"https://github.com/PhilippeBoisney/ModernSearchBar/raw/master/Examples%20Url/exampleB.png"))self.modernSearchBar.setDatasWithUrl(datas: suggestionListWithUrl)

    委托

    ModernSearchBarDelegate从UISearchBarDelegate继承,因此你可以找到你在项目中已经使用的共享方法。 另外,我还添加了这些方法来处理suggestionsView上的单击操作。

    ///Called if you use String suggestion listfunconClickItemSuggestionsView(item: String) {
     print("User touched this item: "+item)
    }///Called if you use Custom Item suggestion listfunconClickItemWithUrlSuggestionsView(item: ModernSearchBarModel) {
     print("User touched this item: "+item.title+" with this url: "+item.url.description)
    }///Called when user touched shadowViewfunconClickShadowView(shadowView: UIView) {
     print("User touched shadowView")
    }

    定制

    //Modify shadows alphaself.modernSearchBar.shadowView_alpha=0.8//Modify the default icon of suggestionsView's rowsself.modernSearchBar.searchImage= ModernSearchBarIcon.Icon.none.image//Modify properties of the searchLabelself.modernSearchBar.searchLabel_font=UIFont(name: "Avenir-Light", size: 30)self.modernSearchBar.searchLabel_textColor= UIColor.redself.modernSearchBar.searchLabel_backgroundColor= UIColor.black//Modify properties of the searchIconself.modernSearchBar.suggestionsView_searchIcon_height=40self.modernSearchBar.suggestionsView_searchIcon_width=40self.modernSearchBar.suggestionsView_searchIcon_isRound=false//Modify properties of suggestionsView///Modify the max height of the suggestionsViewself.modernSearchBar.suggestionsView_maxHeight=1000///Modify properties of the suggestionsViewself.modernSearchBar.suggestionsView_backgroundColor= UIColor.brownself.modernSearchBar.suggestionsView_contentViewColor= UIColor.yellowself.modernSearchBar.suggestionsView_separatorStyle=. singleLineself.modernSearchBar.suggestionsView_selectionStyle= UITableViewCellSelectionStyle.grayself.modernSearchBar.suggestionsView_verticalSpaceWithSearchBar=10self.modernSearchBar.suggestionsView_spaceWithKeyboard=20

    版本

    1.5

    许可证

    版权所有 2017 Boisney Philippe

    在Apache许可以证下许可以证版本 2.0 ("许可以证") ;你可以能不使用这里文件,除了符合许可以证。 你可以获得许可证的副本在*

    http://www.apache.org/licenses/LICENSE-2.0

    在规定的法律或者书面许可下,在许可条款下分发的软件在不保证任何种类的担保或者条件的前提下分发,或者明示或者隐含。 查看许可协议下特定语言的许可权限和限制的许可证。

    • fork
    • 创建你的特征分支( git checkout -b my-new-feature )
    • 提交你的更改( git commit -am 'Add some feature' )
    • 推送到分支( git push origin my-new-feature )
    • 创建新拉请求

    作者

    Philippe BOISNEY (phil.boisney(@)gmail.com)




    Copyright © 2011 HelpLib All rights reserved.    知识分享协议 京ICP备05059198号-3  |  如果智培  |  酷兔英语