         )
     }
     
-    func searchButtonAction(_ sender: AnyObject) {
+    open func searchButtonAction(_ sender: AnyObject) {
         UIView.animate(
             withDuration: 0.5,
             animations: {

    
    weak var delegate: CNLSearchControllerDelegate?
    
    var searchQueryText: String?
    
    var searchBar = UISearchBar()
    var searchBarButtonItem: UIBarButtonItem!
    var searchButton: UIButton!
    var navigationItem: UINavigationItem!
    
    func setupWithDelegate(_ delegate: CNLSearchControllerDelegate, navigationItem: UINavigationItem, searchQueryText: String? = nil) {
        self.delegate = delegate
        searchButton = UIButton(frame: CGRect(x: 0, y: 0, width: 30, height: 30))
        searchButton.setImage(UIImage(named: "NavBar Search"), for: UIControlState())
        searchButton.imageEdgeInsets = UIEdgeInsetsMake(5, 5, 5, 5)
        searchButton.addTarget(self, action: #selector(searchButtonAction(_:)), for: .touchUpInside)
        searchBarButtonItem = UIBarButtonItem(customView: searchButton)

        activate()
    }
    
    open func activate() {
        navigationItem.rightBarButtonItem = searchBarButtonItem
    }
    
    open func deactivate(_ animated: Bool) {
        searchBar.resignFirstResponder()
        if let _ = navigationItem.titleView {
            hideSearchBar(animated)
        }
    }
    
    open func hideSearchBar(_ animated: Bool) {
        searchBar.text = nil
        if (searchQueryText ?? "") != "" {
            searchBarSearchButtonClicked(searchBar)
