I wish to change the title of the cancel button in iOS. I have been using this previously:
- (void)searchDisplayControllerWillBeginSearch:(UISearchDisplayCon
For Swift 3.0
This is working fine.
func setSearchButtonText(text:String,searchBar:UISearchBar) {
for subview in searchBar.subviews {
for innerSubViews in subview.subviews {
if let cancelButton = innerSubViews as? UIButton {
cancelButton.setTitleColor(UIColor.white, for: .normal)
cancelButton.setTitle(text, for: .normal)
}
}
}
}
And call the method
setSearchButtonText(text: "Done", searchBar: yourSearchBar)
Here is the output