Change UISearchBar cancel button text in iOS 8
问题 I'd like to change the text from ¨Cancel¨to ¨Done¨ of the Cancel button inside the UISearchBar in iOS 8. I am using UISearchController. I've tried different approaches for iOS 6 and iOS 7 and they do not work. Has anybody done this? 回答1: Objective-C: [searchBar setValue:@"customString" forKey:@"_cancelButtonText"]; Swift: searchBar.setValue("customString", forKey:"_cancelButtonText") 回答2: This worked for me in ios8, did not try in ios7, but should do the trick, beware of placing this line in