title: Change UISearchBar Cancel button to icon
body: <p>I want to change the <code>UISearchBar</code>'s <code>Cancel</code> button to one that only has an image, and no text. Here's where I got to so far from original behaviour</p>
  
  <p><a href="https://i.stack.imgur.com/rPrIB.png" rel="noreferrer"><img src="https://i.stack.imgur.com/rPrIB.png" alt="enter image description here"></a></p>
  
  <p>to this</p>
  
  <p><a href="https://i.stack.imgur.com/GipDl.png" rel="noreferrer"><img src="https://i.stack.imgur.com/GipDl.png" alt="enter image description here"></a></p>
  
  <p>A step in the right direction, but the problem is the button is too wide. When I debug the view, I can see that it has button label insets of 11 points on left and right. <strong>Does anyone know how to make the button fit the content size?</strong> The image is square.</p>
  
  <p>Here's my code for customising the button:</p>
  
  <pre><code>UIBarButtonItem *barButtonAppearanceInSearchBar;
  
  if (IOS9) {
      barButtonAppearanceInSearchBar = [UIBarButtonItem appearanceWhenContainedInInstancesOfClasses:@[[UISearchBar class]]];
  } else {
      barButtonAppearanceInSearchBar = [UIBarButtonItem appearanceWhenContainedIn:[UISearchBar class], nil];
  }
  
  barButtonAppearanceInSearchBar.image = [UIImage imageNamed:@"Close"];
  barButtonAppearanceInSearchBar.title = nil;
  </code></pre>
  
  <p>Another weird issue is that when I dismiss the search bar and activate it again, the button image turns dark (it's still there, I can see it when debugging the views), so it looks like this</p>
  
  <p><a href="https://i.stack.imgur.com/VPRIy.png" rel="noreferrer"><img src="https://i.stack.imgur.com/VPRIy.png" alt="enter image description here"></a></p>
  
  <p><strong>Any idea how to keep the icon white?</strong> I tried this method below, but without results:</p>
  
  <pre><code>- (void)willPresentSearchController:(UISearchController *)searchController {
  
      searchController.searchBar.tintColor = [UIColor whiteColor];
  }
  </code></pre>