DAOSearchBar 1.3.0

DAOSearchBar 1.3.0

测试已测试
语言语言 SwiftSwift
许可证 WTFPL
发布最新版本2022年9月
SPM支持SPM

Maintained by Ray Dandaoseng33




  • 作者:
  • daoseng33

DAOSearchBar

INSSearchBar是一个拥有美丽动画的第三方搜索栏。不幸的是,看起来INSSearchBar已经不再更新了。

因此,这里提供了DAOSearchBar。

withoutDelegate withDelegate customColor

要求

  • iOS 12.0及以上

  • Swift 3.0及以上(支持Swift 5.0)

安装

CocoaPods

pod 'DAOSearchBar', '~> 1.3'

用法

无前委托的搜索栏

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)

有委托的搜索栏

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)

自定义颜色

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

委托

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
   }