I want to hide the Navigation Bar of my page when the user start editing on the searchbar, I also want to show a cancel button. It is done but my cancel button is not access
Swift 4:
Below 2 lines of code worked for me to show cancel button:
searchBar.setShowsCancelButton(true, animated: true) searchBar.showsCancelButton = true
Calling inside searchBarTextDidBeginEditing() method will show cancel button after clicking on search bar.
searchBarTextDidBeginEditing()