Change UISearchBar cancel button text in iOS 8

后端 未结 13 1586
感动是毒
感动是毒 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:48

    Found it!. in iOS 8, the cancel button is under the key "cancelButton". I used UISearchBar delegate searchBarTextDidBeginEditing to make the change.

    func searchBarTextDidBeginEditing(searchBar: UISearchBar) {
        let uiButton = searchBar.valueForKey("cancelButton") as UIButton
        uiButton.setTitle("Done", forState: UIControlState.Normal)
    
    }
    
    0 讨论(0)
提交回复
热议问题