http://stackoverflow.com/questions/28642807/uisearchcontroller-change-cancel-button-title
swift version:
for view:UIView in (searchView?.subviews)!
{
for subView:UIView in (view.subviews)
{
if ( subView is UIButton )
{
let cancelBut = subView as! UIButton
//do stuff with cancelButton here
}
}
}
You can change the "Cancel" Button in search bar using this-
for (UIView *view in searchBar.subviews)
{
for (id subview in view.subviews)
{
if ( [subview isKindOfClass:[UIButton class]] )
{
[subview setEnabled:YES];
UIButton cancelButton = (UIButton)subview;
[cancelButton setTitle:@"hi" forState:UIControlStateNormal];
NSLog(@"enableCancelButton");
return;
}
}
}