UISearchBar's set_cancelButtonText: ivar is prohibited

元气小坏坏 提交于 2019-12-04 12:50:17

Instead of messing around with the undocumented view hierarchy, you can use UIAppearance:

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

For Objective-C , You can use this if you have problem with UISearchController or change it however you're using.

[[UINavigationBar appearanceWhenContainedInInstancesOfClasses:@[[UISearchController class]]] prefersLargeTitles];

Objective-C version:

[[UIBarButtonItem appearanceWhenContainedInInstancesOfClasses:@[[UISearchBar class]]] setTitle:@"CancelText"];

UISearchDisplayController is deprecated since iOS 8.0 avoid using it

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!