{"id":2967,"url":"https://github.com/apasccon/SearchTextField","last_synced_at":"2025-08-03T12:31:43.202Z","repository":{"id":39487202,"uuid":"57380210","full_name":"apasccon/SearchTextField","owner":"apasccon","description":"UITextField subclass with autocompletion suggestions list","archived":false,"fork":false,"pushed_at":"2023-06-25T18:25:08.000Z","size":13461,"stargazers_count":1149,"open_issues_count":122,"forks_count":253,"subscribers_count":23,"default_branch":"master","last_synced_at":"2025-07-24T23:16:59.148Z","etag":null,"topics":["autocomplete","autocomplete-suggestions","dropdown","searching","swift","uitextfield"],"latest_commit_sha":null,"homepage":null,"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/apasccon.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2016-04-29T11:45:17.000Z","updated_at":"2025-06-30T20:30:57.000Z","dependencies_parsed_at":"2023-10-20T17:30:16.600Z","dependency_job_id":null,"html_url":"https://github.com/apasccon/SearchTextField","commit_stats":{"total_commits":108,"total_committers":17,"mean_commits":6.352941176470588,"dds":"0.17592592592592593","last_synced_commit":"6c3ecdd34c4c910af9e1f7c5ee05f3e0bae05623"},"previous_names":[],"tags_count":26,"template":false,"template_full_name":null,"purl":"pkg:github/apasccon/SearchTextField","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/apasccon%2FSearchTextField","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/apasccon%2FSearchTextField/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/apasccon%2FSearchTextField/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/apasccon%2FSearchTextField/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/apasccon","download_url":"https://codeload.github.com/apasccon/SearchTextField/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/apasccon%2FSearchTextField/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":267517322,"owners_count":24100491,"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","status":"online","status_checked_at":"2025-07-28T02:00:09.689Z","response_time":68,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["autocomplete","autocomplete-suggestions","dropdown","searching","swift","uitextfield"],"created_at":"2024-01-05T20:16:27.659Z","updated_at":"2025-08-03T12:31:42.725Z","avatar_url":"https://github.com/apasccon.png","language":"Swift","funding_links":[],"categories":["UI","HarmonyOS","Content"],"sub_categories":["TextField \u0026 TextView","Other free courses","Windows Manager","Text Field"],"readme":"![alt_tag](https://raw.githubusercontent.com/apasccon/SearchTextField/master/Example/SearchTextField/SearchTextField.png)\n\n# SearchTextField\n\n[![Version](https://img.shields.io/cocoapods/v/SearchTextField.svg?style=flat)](http://cocoapods.org/pods/SearchTextField)\n[![License](https://img.shields.io/cocoapods/l/SearchTextField.svg?style=flat)](http://cocoapods.org/pods/SearchTextField)\n[![Platform](https://img.shields.io/cocoapods/p/SearchTextField.svg?style=flat)](http://cocoapods.org/pods/SearchTextField)\n\n## Overview\n\n**SearchTextField** is a subclass of UITextField, written in Swift that makes really easy the ability to show an autocomplete suggestions list.   \nYou can decide wether to show the list as soon as the field is focused or when the user starts typing.   \nYou can also detects when the user stops typing, very useful when you can get a suggestion list from a remote server.   \n\n**New Feature!**\nNow you can make suggestions \"inline\", showing the first matched result as the placeholder (instead of the results list) and selecting it when the user touches the enter key.\n\n------   \n![alt_tag](https://raw.githubusercontent.com/apasccon/SearchTextField/master/Example/SearchTextField/SearchTextField_Demo.gif)\n\n## Requirements\n\n* iOS 9\n\n## Installation\n\nSearchTextField is available through [CocoaPods](http://cocoapods.org). To install\nit, simply add the following line to your Podfile:\n\n```swift\nuse_frameworks!\n\npod \"SearchTextField\"\n```\n\n### Manual installation\n\nJust import SearchTextField.swift into your project\n\n## Usage\n\n### You can use it in the simplest way...\n\n```swift\nimport SearchTextField\n\n// Connect your IBOutlet...\n@IBOutlet weak var mySearchTextField: SearchTextField!\n\n// ...or create it manually\nlet mySearchTextField = SearchTextField(frame: CGRectMake(10, 100, 200, 40))\n\n// Set the array of strings you want to suggest\nmySearchTextField.filterStrings([\"Red\", \"Blue\", \"Yellow\"])\n```\n### ...or you can customize it as you want\n\n```swift\n// Show also a subtitle and an image for each suggestion:\n\nlet item1 = SearchTextFieldItem(title: \"Blue\", subtitle: \"Color\", image: UIImage(named: \"icon_blue\"))\nlet item2 = SearchTextFieldItem(title: \"Red\", subtitle: \"Color\", image: UIImage(named: \"icon_red\"))\nlet item3 = SearchTextFieldItem(title: \"Yellow\", subtitle: \"Color\", image: UIImage(named: \"icon_yellow\"))\nmySearchTextField.filterItems([item1, item2, item3])\n\n// Set a visual theme (SearchTextFieldTheme). By default it's the light theme\nmySearchTextField.theme = SearchTextFieldTheme.darkTheme()\n\n// Modify current theme properties\nmySearchTextField.theme.font = UIFont.systemFontOfSize(12)\nmySearchTextField.theme.bgColor = UIColor (red: 0.9, green: 0.9, blue: 0.9, alpha: 0.3)\nmySearchTextField.theme.borderColor = UIColor (red: 0.9, green: 0.9, blue: 0.9, alpha: 1)\nmySearchTextField.theme.separatorColor = UIColor (red: 0.9, green: 0.9, blue: 0.9, alpha: 0.5)\nmySearchTextField.theme.cellHeight = 50\n\n// Set specific comparision options - Default: .caseInsensitive\nmySearchTextField.comparisonOptions = [.caseInsensitive]\n\n// Set the max number of results. By default it's not limited\nmySearchTextField.maxNumberOfResults = 5\n\n// You can also limit the max height of the results list\nmySearchTextField.maxResultsListHeight = 200\n\n// Customize the way it highlights the search string. By default it bolds the string\nmySearchTextField.highlightAttributes = [NSBackgroundColorAttributeName: UIColor.yellowColor(), NSFontAttributeName:UIFont.boldSystemFontOfSize(12)]\n\n// Handle what happens when the user picks an item. By default the title is set to the text field\nmySearchTextField.itemSelectionHandler = {item, itemPosition in\n    mySearchTextField.text = item.title\n}\n\n// You can force the results list to support RTL languages - Default: false\nmySearchTextField.forceRightToLeft = true\n\n// Show the list of results as soon as the user makes focus - Default: false\nmySearchTextField.startVisible = true\n\n// ...or show the list of results even without user's interaction as soon as created - Default: false\nmySearchTextField.startVisibleWithoutInteraction = true\n\n// Start filtering after an specific number of characters - Default: 0\nmySearchTextField.minCharactersNumberToStartFiltering = 3\n\n// Force to show the results list without filtering (but highlighting)\nmySearchTextField.forceNoFiltering = true\n\n// Explicitly hide the results list\nmySearchTextField.hideResultsList()\n\n/**\n* Update data source when the user stops typing.\n* It's useful when you want to retrieve results from a remote server while typing\n* (but only when the user stops doing it)\n**/\nmySearchTextField.userStoppedTypingHandler = {\n    if let criteria = self.mySearchTextField.text {\n        if criteria.characters.count \u003e 1 {\n\n            // Show the loading indicator\n            self.mySearchTextField.showLoadingIndicator()\n\n            self.searchMoreItemsInBackground(criteria) { results in\n                // Set new items to filter\n                self.mySearchTextField.filterItems(results)\n\n                // Hide loading indicator\n                self.mySearchTextField.stopLoadingIndicator()\n            }\n        }\n    }\n}\n\n// Handle item selection - Default behaviour: item title set to the text field\nmySearchTextField.itemSelectionHandler = { filteredResults, itemPosition in\n    // Just in case you need the item position\n    let item = filteredResults[itemPosition]\n    print(\"Item at position \\(itemPosition): \\(item.title)\")\n\n    // Do whatever you want with the picked item\n    self.mySearchTextField.text = item.title\n}\n\n// Define a results list header - Default: nothing\nlet header = UILabel(frame: CGRect(x: 0, y: 0, width: acronymTextField.frame.width, height: 30))\nheader.backgroundColor = UIColor.lightGray.withAlphaComponent(0.3)\nheader.textAlignment = .center\nheader.font = UIFont.systemFont(ofSize: 14)\nheader.text = \"Pick your option\"\nmySearchTextField.resultsListHeader = header\n\n\n\n```\n\n### New feature: show the first matched result as placeholder (inline mode)\n\n```swift\n// Set the array of strings you want to suggest\nmySearchTextField.filterStrings([\"Red\", \"Blue\", \"Yellow\"])\n\n// Then set the inline mode in true\nmySearchTextField.inlineMode = true\n```\n\n### New feature: autocomplete from, for example, a list of email domains\n\n```swift\nemailInlineTextField.inlineMode = true\nemailInlineTextField.startFilteringAfter = \"@\"\nemailInlineTextField.startSuggestingInmediately = true\nemailInlineTextField.filterStrings([\"gmail.com\", \"yahoo.com\", \"yahoo.com.ar\"])\n```\n\n## Swift Versions\n\nSwift 5 supported from 1.2.3 version.\n\nSwift 4 supported from 1.2.0 version.\n\nInstall v1.0.0 if you need to support Swift 2.3.\n\nInstall v1.0.2 and above if you want to support Swift 3.\n\n\n## Demo\n\nCheck out the Example project.\n\n## Author\n\nAlejandro Pasccon, apasccon@gmail.com\n\n## License\n\nSearchTextField 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%2Fapasccon%2FSearchTextField","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fapasccon%2FSearchTextField","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fapasccon%2FSearchTextField/lists"}