I\'d like to change the text from "Cancel" to "Done" of the Cancel button inside the UISearchBar in iOS 8. I am using UISearchControll
for view in (UISearchBar.subviews[0]).subviews{
if let button = view as? UIButton{
button.setTitleColor(UIColor.whiteColor(), forState: .Normal)
button.setTitle("Cancel", forState:.Normal)
}
}
self.subviews[0]).subviews contain UISearchBarBackground,UISearchBarTextField,UINavigationButton in which UINavigationButton is subclass of UIButton.Check for View as UIButton and if yes then change property of UIButton.