{"id":2928,"url":"https://github.com/younatics/YNSearch","last_synced_at":"2025-08-06T16:30:48.096Z","repository":{"id":50620916,"uuid":"88394399","full_name":"younatics/YNSearch","owner":"younatics","description":"🔍 Awesome fully customize search view like Pinterest written in Swift 5.0 + Realm support!","archived":false,"fork":false,"pushed_at":"2019-03-31T08:31:56.000Z","size":6384,"stargazers_count":1192,"open_issues_count":3,"forks_count":104,"subscribers_count":25,"default_branch":"master","last_synced_at":"2024-11-21T13:11:53.327Z","etag":null,"topics":["ios","pinterest","realm","realmswift","search","searchbar","swift"],"latest_commit_sha":null,"homepage":"https://www.cocoacontrols.com/controls/ynsearch","language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/younatics.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-04-16T05:59:12.000Z","updated_at":"2024-11-19T00:55:35.000Z","dependencies_parsed_at":"2022-09-22T14:25:31.287Z","dependency_job_id":null,"html_url":"https://github.com/younatics/YNSearch","commit_stats":null,"previous_names":[],"tags_count":20,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/younatics%2FYNSearch","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/younatics%2FYNSearch/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/younatics%2FYNSearch/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/younatics%2FYNSearch/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/younatics","download_url":"https://codeload.github.com/younatics/YNSearch/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":228923679,"owners_count":17992566,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ios","pinterest","realm","realmswift","search","searchbar","swift"],"created_at":"2024-01-05T20:16:26.558Z","updated_at":"2024-12-09T16:30:59.334Z","avatar_url":"https://github.com/younatics.png","language":"Swift","funding_links":[],"categories":["UI","Libs","Swift","UI [🔝](#readme)","📦 Miscellaneous","User Interface"],"sub_categories":["Tag","UI","Other free courses","🏆 Top 25","Mobile"],"readme":"# YNSearch + Realm Support\n\n[![Awesome](https://cdn.rawgit.com/sindresorhus/awesome/d7305f38d29fed78fa85652e3a63e154dd8e8829/media/badge.svg)](https://github.com/sindresorhus/awesome)\n[![Version](https://img.shields.io/cocoapods/v/YNSearch.svg?style=flat)](http://cocoapods.org/pods/YNSearch)\n[![Carthage Compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/Carthage/Carthage)\n[![License: MIT](https://img.shields.io/badge/license-MIT-blue.svg?style=flat)](https://github.com/younatics/YNSearch/blob/master/LICENSE)\n[![Build Status](https://travis-ci.org/younatics/YNSearch.svg?branch=master)](https://travis-ci.org/younatics/YNSearch)\n[![Platform](https://img.shields.io/cocoapods/p/YNSearch.svg?style=flat)](http://cocoapods.org/pods/YNSearch)\n[![Swift 5.0](https://img.shields.io/badge/Swift-5.0-blue.svg?style=flat)](https://developer.apple.com/swift/)\n\n## Updates\nSee [CHANGELOG](https://github.com/younatics/YNSearch/blob/master/CHANGELOG.md) for details\n\n## Intoduction\n🔍 Awesome search view, written in Swift 5.0, appears search view like Pinterest Search view. You can fully customize this library. You can also use this library with Realm! See usage in below\n#### See [Highlighter](https://github.com/younatics/Highlighter) for highlight search result\n\n![demo2](Images/Highlighter.gif)\n![demo](Images/YNSearch.gif)\n![demo3](Images/YNSearch2.png)\n![demo4](Images/YNSearch3.png)\n\n## Requirements\n\n`YNSearch` is written in Swift 5.0. Compatible with iOS 8.0+\n\n## Installation\n\n### Cocoapods\n\nYNSearch is available through [CocoaPods](http://cocoapods.org). To install\nit, simply add the following line to your Podfile:\n\n```ruby\npod 'YNSearch'\n```\n\n### Carthage\n```\ngithub \"younatics/YNSearch\"\n```\n\n## Simple Usage\nSet categories (required) and search histories (optional)\n```swift\nimport YNSearch\n\nlet demoDatabase = [\"Menu\", \"Animation\", \"Transition\", \"TableView\", \"CollectionView\", \"Indicator\", \"Alert\", \"UIView\", \"UITextfield\", \"UITableView\", \"Swift\", \"iOS\", \"Android\"]\n\nynSearch.setCategories(value: demoDatabase)\nynSearch.setSearchHistories(value: demoDatabase)\n\nself.ynSearchinit()\n```\n\nSet database (required) and key (required). key will be displayed in `YNSearchListView` You can set your database `[Any]` if you want to customize. \n```swift\nlet database1 = YNDropDownMenu(key: \"YNDropDownMenu\")\nlet database2 = YNSearchData(key: \"YNSearchData\")\nlet demoDatabase = [database1, database2]\n        \nself.initData(database: demoDatabase)\n```\n\nSet `YNSearchListView` Delegate\n```Swift\nfunc ynSearchListView(_ ynSearchListView: UITableView, cellForRowAt indexPath: IndexPath) -\u003e UITableViewCell {\n        let cell = self.ynSearchView.ynSearchListView.dequeueReusableCell(withIdentifier: YNSearchListViewCell.ID) as! YNSearchListViewCell\n        if let ynmodel = self.ynSearchView.ynSearchListView.searchResultDatabase[indexPath.row] as? YNSearchModel {\n            cell.searchLabel.text = ynmodel.key\n        }\n        \n        return cell\n}\n    \nfunc ynSearchListView(_ ynSearchListView: UITableView, didSelectRowAt indexPath: IndexPath) {\n        if let ynmodel = self.ynSearchView.ynSearchListView.searchResultDatabase[indexPath.row] as? YNSearchModel, let key = ynmodel.key {\n        // Call listview clicked based on key\n        self.ynSearchView.ynSearchListView.ynSearchListViewDelegate?.ynSearchListViewClicked(key: key)\n        \n        // return object you set in database\n        self.ynSearchView.ynSearchListView.ynSearchListViewDelegate?.ynSearchListViewClicked(object: self.ynSearchView.ynSearchListView.database[indexPath.row])\n        \n        // Append Search history\n        self.ynSearchView.ynSearchListView.ynSearch.appendSearchHistories(value: key)\n        }\n}\n```\n\n## Realm Usage\nGet your Data with Realm\n```Swift \nlet datas = realm.objects(RealmModel.self)\n```\nRealm is not collection type so you need to convert it again with `[Any]`type. This will find all string in your RealmModel and show you results.\n```Swift \nvar dataArray = [Any]()\nfor data in datas {\n        let searchModel = RealmModel()\n            searchModel.author = data.author\n            searchModel.detail = data.detail\n            searchModel.title = data.title\n            searchModel.type = data.type\n            \n            dataArray.append(searchModel)\n        }\n        \nself.initData(database: dataArray)\n```\n\n\n#### I used [Objectification](https://github.com/younatics/Objectification) for accurate search result. This library will get all data in your object and search if for us.\nDone!\n\n## View Hierachy\n```\nYNSearchViewController: Inherit this viewcontroller \n|-- YNSearchTextFieldView: YNSearchTextField with cancel button\n|   |-- YNSearchTextField: Search UITextfield\n|   |-- cancelButton: Show when YNSearchTextField textFieldDidBeginEditing\n|\n|-- YNSearchView : get both YNSearchMainView and YNSearchListView\n|   |-- YNSearchMainView: First view that you can see\n|   |   |-- categoryLabel: Cateogry label\n|   |   |-- [YNCategoryButton]: cateogory buttons\n|   |   |-- searchHistoryLabel: Search history label\n|   |   |-- [YNSearchHistoryView]: history views\n|   |   |   |-- [YNSearchHistoryButton]: Search history button\n|   |   |   |-- [closeButton]: Close button\n|   |\n|   |-- YNSearchListView: UITableview with search result\n```\n\n## Custom Usage\nset `YNSearchDelegate` if you want callback\n```Swift \nself.delegate = self\n\nfunc ynSearchHistoryButtonClicked(text: String) {\n  print(text)\n}\n    \nfunc ynCategoryButtonClicked(text: String) {\n  print(text)\n}\n    \nfunc ynSearchListViewClicked(text: String) {\n  print(text)\n}\n\nfunc ynSearchListViewClicked(object: YNSearchModel) {\n  print(object)\n}\n```\n\nSet `YNCategoryButton` type.\n```Swift\nself.ynSearchView.ynSearchMainView.setYNCategoryButtonType(type: .colorful)\n```\n\nSee more usage in demo\n\n#### You can fully customize this `YNSearch` based on view hierachy\n\n## References\n#### Please tell me or make pull request if you use this library in your application :) \n#### [Highlighter](https://github.com/younatics/Highlighter)\n#### [Objectification](https://github.com/younatics/Objectification)\n#### [MotionBook](https://github.com/younatics/MotionBook)\n\n## Author\n[younatics](https://twitter.com/younatics)\n\u003ca href=\"http://twitter.com/younatics\" target=\"_blank\"\u003e\u003cimg alt=\"Twitter\" src=\"https://img.shields.io/twitter/follow/younatics.svg?style=social\u0026label=Follow\"\u003e\u003c/a\u003e\n\n## License\nYNSearch is available under the MIT license. See the LICENSE file for more info.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyounatics%2FYNSearch","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyounatics%2FYNSearch","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyounatics%2FYNSearch/lists"}