Latest 1.0.4
Homepage https://github.com/vincentLin113/SwiftySearch
License MIT
Platforms ios 9.0
Authors

Swift
Cocoapods Compatible

Awesome iOS UISearchController with multi-feature, base on PYSearch.

Base + hiddenStatusBar Custom NavigationBar Custom TextColor
sample sample sample

features

  • [x] Support search suggestions
  • [x] Support search history (record) cache
  • [x] Support callback using delegate or block completion search
  • [x] Support CocoaPods
  • [x] Support localization

Requirements

  • iOS 9.0+
  • Swift 3.0+

Installation

CocoaPods

available on CocoaPods. Just add the following to your project Podfile:

pod 'SwiftySearch'
use_frameworks!

Usage

See the code snippet below for an example of how to implement, or see the example project.

Create
Declare SwiftySearchController and custom navigationTitle/cancelTextColor/navigationTitleColor

let search: SwiftySearchController = {
            let _search = SwiftySearchController().configure {
                $0.receiveTitle = currentTitle
                $0.cancelTextColor = .blue
                $0.navigationTitleColor = .green
                $0.displayStatusBar = true
            }
            return _search
        }()

Custom color

            search.navigationLeftColor = .red
            search.navigationRightColor = .blue
            search.cancelTextColor = .white

Custom Text

            search.searchBarPlaceholder = "Avengers"
            search.cancelButtonText = "Close"
            search.receiveSearchText = "Thor"
            search.receiveHotSearchs = ["Eminem", "Macklemore", "Post Malone", "Jay Chou", "Sia", "Taylor Swift", "Kendrick Lamar"]
            search.receiveTitle = "SwiftyTitle"

Custom Image

           SwiftySearchCellCustom.cleanButtonIconImage = yourImage

Search History

           search.maxOfSearchRecords = 10

Set hot search

           search.hotSearchs = ["Black Widow", "Iron Man", "Captain America", "Thor", "Hulk", "Black Panther", "Hawkeye"]

Bonus Customization


    public static var cursorColor: UIColor = UIColor.Blue.mainBlue

    public static var searchRecordOptionButtonBorderColor: UIColor

    public static var searchRecordOptionButtonTextColor: UIColor

    public static var hotSearchOptionButtonBorderColor: UIColor

    public static var hotSearchOptionButtonTextColor: UIColor

    public static var swapSearchRecordWithHotSearch: Bool

Set recommendation text in Delegate

func searchBarTextDidChange(_ searchViewController: SwiftySearchController, searchBar: UISearchBar, searchText: String) {
        var recommendations: [String] = []
        switch currentIndex {
        case 0:
            recommendations = ["Indie Pop", "Jazz", "Latin", "Opera", "Vocal", "Rap"]
        case 1:
            recommendations = ["Loki", "Ronan" ,"Red Skull" ,"Ultron", "Dr.Doom", "Mystique", "Black Cat"]
        case 2:
            recommendations = ["Not Afraid", "Thrift Shop", "Congratulations", "不愛就拉倒", "Genius", "Look What You Made Me Do", "HUMBLE."]
        default:
            break;
        }
        searchViewController.receiveRecommendationTextArray = recommendations
    }

IMPORTANT

If you are going to present SwiftySearch, you need to use UINavigationController.

          let navi = UINavigationController(rootViewController: search)
          self.present(navi, animated: true, completion: nil)

Delegate

There’s some trigger point you can handle using delegate. those are optional.
See SwiftySearchController for more details.

  • func didSelectedRecommendation(_, index: Int,recommendationText: String,searchText: String)
    • func didSelectedHotSearch(_ , index: Int,hotSearch: String, searchText: String)
    • func didSelectedSearchRecord(_,index: Int,searchRecordText: String,searchText: String)
    • func searchBarTextDidChange(_,searchBar: UISearchBar,searchText: String)
    • func searchBarTextDidEndEditing(_ ,searchBar: UISearchBar)
    • func didSelectedCleanButton(_ ,cleanButton: UIButton)

Hope

  • If you have many questions, you can put issue issue.

Photos from

License

available under the MIT license. See the LICENSE file for more info.

Latest podspec

{
    "name": "SwiftySearch",
    "version": "1.0.4",
    "summary": "Awesome iOS UISearchController with multi-feature.",
    "description": "Search History + Hot Search + Customization + Localized SearchController",
    "homepage": "https://github.com/vincentLin113/SwiftySearch",
    "license": "MIT",
    "authors": {
        "VincentLin": "[email protected]"
    },
    "platforms": {
        "ios": "9.0"
    },
    "source": {
        "git": "https://github.com/vincentLin113/SwiftySearch.git",
        "tag": "1.0.4"
    },
    "source_files": "SwiftySearch/Source/*.{swift,metal,h,m}",
    "resources": [
        "SwiftySearch/Source/SwiftySearchResource.bundle",
        "SwiftySearch/Source/**/*.strings"
    ],
    "swift_version": "3.3"
}

Pin It on Pinterest

Share This