- July 26, 2025
- Mins Read
This search bar will allow you to offer suggestions words to your users when they are looking for something using default iOS search bar. Enjoy it !
Two ways to use this lib :
SIMPLE | ADVANCED |
---|---|
![]() |
![]() |
You can use CocoaPods to install ModernSearchBar
by adding it to your Podfile
:
pod ‘ModernSearchBar’
//Import lib on the top of ViewController
import ModernSearchBar
//Create an IBOutlet from your searchBar
@IBOutlet weak var modernSearchBar: ModernSearchBar!
//Extend your ViewController with ‘ModernSearchBarDelegate’
class ViewController: UIViewController, ModernSearchBarDelegate
//Implement the delegation
self.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 inherit from UISearchBarDelegate, so you can find commons methods you already use in your project. Also, I add those methods to handle click actions on suggestionsView.
///Called if you use String suggestion list
func onClickItemSuggestionsView(item: String) {
print(“User touched this item: “+item)
}
///Called if you use Custom Item suggestion list
func onClickItemWithUrlSuggestionsView(item: ModernSearchBarModel) {
print(“User touched this item: “+item.title+” with this url: “+item.url.description)
}
///Called when user touched shadowView
func onClickShadowView(shadowView: UIView) {
print(“User touched shadowView”)
}
//Modify shadows alpha
self.modernSearchBar.shadowView_alpha = 0.8
//Modify the default icon of suggestionsView’s rows
self.modernSearchBar.searchImage = ModernSearchBarIcon.Icon.none.image
//Modify properties of the searchLabel
self.modernSearchBar.searchLabel_font = UIFont(name: “Avenir-Light”, size: 30)
self.modernSearchBar.searchLabel_textColor = UIColor.red
self.modernSearchBar.searchLabel_backgroundColor = UIColor.black
//Modify properties of the searchIcon
self.modernSearchBar.suggestionsView_searchIcon_height = 40
self.modernSearchBar.suggestionsView_searchIcon_width = 40
self.modernSearchBar.suggestionsView_searchIcon_isRound = false
//Modify properties of suggestionsView
///Modify the max height of the suggestionsView
self.modernSearchBar.suggestionsView_maxHeight = 1000
///Modify properties of the suggestionsView
self.modernSearchBar.suggestionsView_backgroundColor = UIColor.brown
self.modernSearchBar.suggestionsView_contentViewColor = UIColor.yellow
self.modernSearchBar.suggestionsView_separatorStyle = .singleLine
self.modernSearchBar.suggestionsView_selectionStyle = UITableViewCellSelectionStyle.gray
self.modernSearchBar.suggestionsView_verticalSpaceWithSearchBar = 10
self.modernSearchBar.suggestionsView_spaceWithKeyboard = 20
1.5
NavigationKit is a lightweight library which makes SwiftUI navigation super easy to use. 💻 Installation 📦 Swift Package Manager Using Swift Package Manager, add ...
An alternative SwiftUI NavigationView implementing classic stack-based navigation giving also some more control on animations and programmatic navigation. NavigationStack Installation ...
With SwiftUI Router you can power your SwiftUI app with path-based routing. By utilizing a path-based system, navigation in your app becomes ...
This package takes SwiftUI's familiar and powerful NavigationStack API and gives it superpowers, allowing you to use the same API not just ...