CocoaPods trunk is moving to be read-only. Read more on the blog, there are 18 months to go.

DAOSearchBar 1.3.0

DAOSearchBar 1.3.0

TestsTested
LangLanguage SwiftSwift
License WTFPL
ReleasedLast Release Sep 2022
SPMSupports SPM

Maintained by Ray Dan, daoseng33.




  • By
  • daoseng33

DAOSearchBar

INSSearchBar is a 3rd-party search bar with beautiful animation. Unfortunately, it seems like INSSearchBar is no longer update anymore.

So, heres the DAOSearchBar.

withoutDelegate withDelegate customColor

Requirement

  • iOS 12.0 up

  • Swift 3.0 up (Support Swift 5.0)

Installation

CocoaPods

pod 'DAOSearchBar', '~> 1.3'

Usage

Search bar without delegate

self.searchBarWithoutDelegate.frame = CGRect(x: 20.0, y: 64.0, width: self.view.bounds.width - 40.0, height: 34.0)

self.view.addSubview(self.searchBarWithoutDelegate)

Search bar with delegate

class ViewController: UIViewController, DAOSearchBarDelegate {}
self.searchBarWithDelegate.frame = CGRect(x: 20.0, y: 184.0, width: 44.0, height: 34.0)
self.searchBarWithDelegate.delegate = self;

self.view.addSubview(self.searchBarWithDelegate)

Custom color

self.searchBarWithCustomColor.searchOffColor = UIColor.darkGray
self.searchBarWithCustomColor.searchOnColor = UIColor.white
self.searchBarWithCustomColor.searchBarOffColor = UIColor.white
self.searchBarWithCustomColor.searchBarOnColor = UIColor.darkGray

Delegate

func destinationFrameForSearchBar(_ searchBar: DAOSearchBar) -> CGRect
{
return CGRect(x: 20.0, y: 184.0, width: self.view.bounds.size.width - 40.0, height: 34.0)
}
func searchBar(_ searchBar: DAOSearchBar, willStartTransitioningToState destinationState: DAOSearchBarState)
   {
       // Do whatever you deem necessary.
   }
func searchBar(_ searchBar: DAOSearchBar, didEndTransitioningFromState previousState: DAOSearchBarState)
   {
       // Do whatever you deem necessary.
   }
func searchBarDidTapReturn(_ searchBar: DAOSearchBar)
   {
       // Do whatever you deem necessary.
       // Access the text from the search bar like searchBar.searchField.text	
   }
func searchBarTextDidChange(_ searchBar: DAOSearchBar)
   {
       // Do whatever you deem necessary.
       // Access the text from the search bar like searchBar.searchField.text
   }