I have implemented search bar in my app with custom(localized) title.
for the first time when I tap on search it shows cancel button as follow:
First Time

Second Time When I press cancel button & again tap on Search Bar, it looks fine.

My code
   - (void)searchBarTextDidBeginEditing:(UISearchBar *)searchBar
{
    [searchBar setShowsCancelButton:YES animated:YES];
    UIButton *cancelButton;
    UIView *topView = search.subviews[0];
    for (UIView *subView in topView.subviews) {
        if ([subView isKindOfClass:NSClassFromString(@"UINavigationButton")]) {
            cancelButton = (UIButton*)subView;
        }
    }
    if (cancelButton) {
        [cancelButton setTitle:Localized(@"Cancel") forState:UIControlStateNormal];
    }
}
 
     
     
     
     
    