JunsW / FTSearchController

An easy-to-use UISearchController. iOS11 style compatible with iOS10.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

FTSearchController

Build Pass Language

An easy-to-use UISearchController. iOS11 style compatible with iOS10.

Demo

Dwonload and check out the demo project.
iOS 11
iOS 11
iOS 11
iOS 11 lower
Compatible
(I know the demo color pattern is kind of urgly, forgive me :D. I will improve it soon)

Installation

Manual

Download .swift files in Source.

Usage

class ViewController: FTSearchController
Just inherit the FTSearchController.
FTSearchController already provide a UITableView for you to show reuslt.
Just implement the all in one protocol FTSearchControllerDataProvider

###1. Customize UI Setup TextField

  • textFieldBackgroundColor: Backgournd color of textField in searchControler's searchBar
  • textFieldCornerRadius: corner radius of the textField
  • textFieldTextColor: text color of textField
  • textFieldFont: text font of textField
  • cursorColor: Set cursor color by changing the tint color of the searchBar
  • attributedPlaceholder: set up the attributedPlaceholder of the textField
  • leftIconColor: the color of the magnifying lends in the textField
  • rightIconColor: the clear button in the textField

Setup CancelButton

  • customizeCancelButton: (UIButton)->(): a clourse help you setup the cancel button
  • cencelButtonAttributedTitle: This attribute only valid when customizeCancelButton block is nil
  • cancelButtonColor: This attribute only valid when customizeCancelButton block and cencelButtonAttributedTitle is nil
  • cancelButtonTitle: This attribute only valid when customizeCancelButton block and cencelButtonAttributedTitle is nil

Setup Bar

  • hideBorderLines: wether hide the upper and lower border line of the searchBar
  • barBackgroundColor: set the search bar background, only working on iOS 11 lower
  • universalBackgoundColor: set the search bar and the navigationBar background. This attribute will also set searchBar.isTranslucent to false on iOS 11 lower
  • hideNavitionBarBottomLine: wether hide the bottom line of the navigationBar

2. UISearchBar Delegate

The delegate methods of UISearchBar has been convert to closures like below

typealias EmptySearchBarHandler = (UISearchBar)->()
typealias BoolSearchBarHandler = (UISearchBar)->(Bool)

public var searchButtonClickHandler: EmptySearchBarHandler?
public var searchBarShouldBeginEditingHandler: BoolSearchBarHandler?
public var searchBarShouldEndEditingHandler: BoolSearchBarHandler?
public var searchBarCancelButtonClickHandler: EmptySearchBarHandler?

public var searchTextDidChange: ((UISearchBar, String)->())?
public var searchTextShouldChangeInRange: ((UISearchBar, NSRange, String)->(Bool))?

3. FTSearchControllerDataProvider

This protocol simply inherits UITableViewDelegate, UITableViewDataSource, UISearchResultUpdating.

About

An easy-to-use UISearchController. iOS11 style compatible with iOS10.


Languages

Language:Swift 100.0%