swift 3 SearchController SearchBar change buttons texts

时间:2016-10-20 12:37:36

标签: ios swift xcode uisearchbar uisearchcontroller

I have to change the words Search and Cancel from the SearchBar(and the keyboard) when I'm using the search controller.

I have already changed the placeholder like this

searchController.searchBar.placeholder = "My text here..."

But I can't find anything useful for Swift considering the searchBar is constructed programmatically.

searchController.searchResultsUpdater = self
searchController.dimsBackgroundDuringPresentation = false
definesPresentationContext = true
tableView.tableHeaderView = searchController.searchBar

Can anyone help?

UPDATE: so far I managed to change the Cancel button text like this:

searchController.searchBar.setValue("Anuleaza", forKey:"_cancelButtonText")

But could not find a way to change the keyboard word for Search with a custom text.

0 个答案:

没有答案