Skip to content

daoseng33/DAOSearchBar

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

69 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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
   }

About

A search bar with beautiful animation

Resources

License

Stars

Watchers

Forks

Packages

No packages published