Change UISearchBar cancel button text in iOS 8

后端 未结 13 1766
感动是毒
感动是毒 2020-12-13 01:48

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

13条回答
  •  情深已故
    2020-12-13 02:38

    I have added titleLabel.font to the mix...

    This goes straight into my ViewDidLoad() {

            let searchFont = UIFont(name: "BrandonGrotesque-Medium", size: 12)
            let textFieldSearchBar = self.searchBar.valueForKey("searchField") as! UITextField
            textFieldSearchBar.font = searchFont
            let cancelButton = searchBar.valueForKey("cancelButton") as! UIButton
            cancelButton.setTitle("Done", forState: .Normal)
            cancelButton.titleLabel!.font = searchFont
    

提交回复
热议问题