Change UISearchBar cancel button text in iOS 8

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

    I was having trouble getting this to work for a UISearchBar within a UISearchController. The text didn't change the first time the cancel button was shown but it did the second time.

    That is until I saw @polo987's answer. Here's what I did that worked:

    UIBarButtonItem.appearance(whenContainedInInstancesOf: [UISearchBar.self]).title = "Done"
    

提交回复
热议问题