title: UISearchBar clipped under status bar when added to UISearchDisplayController
body: <p>I want my search bar to draw its background extended upwards below the status bar like this:</p>
  <p><img src="https://i.stack.imgur.com/4PTnu.png" alt="enter image description here" /></p>
  <p>This is the corresponding code for the image above:</p>
  <pre><code>- (void)viewDidLoad
  {
      [super viewDidLoad];
  
      self.searchBar = [[UISearchBar alloc] init];
      self.searchBar.delegate = self;
      [self.view addSubview:self.searchBar];
      
      self.searchBar.translatesAutoresizingMaskIntoConstraints = NO;
      NSDictionary *views = @{@&quot;v&quot;:self.searchBar,
                              @&quot;topLayoutGuide&quot;:self.topLayoutGuide};
      
      [self.view addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@&quot;V:[topLayoutGuide][v]&quot; options:0 metrics:nil views:views]];
      [self.view addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@&quot;H:|[v]|&quot; options:0 metrics:nil views:views]];
      
      [self.searchBar setBackgroundImage:[UIImage imageNamed:@&quot;searchbarBG&quot;] forBarPosition:UIBarPositionTopAttached barMetrics:UIBarMetricsDefault];
  }
  
  - (UIBarPosition)positionForBar:(id &lt;UIBarPositioning&gt;)bar
  {
      return UIBarPositionTopAttached;
  }
  </code></pre>
  <p><strong>The problem arises when I add the search bar to a <code>UISearchDisplayController</code></strong> by appending the following line at the end of the <code>viewDidLoad</code> method:</p>
  <pre><code>self.mySearchDisplayController = [[UISearchDisplayController alloc] initWithSearchBar:self.searchBar contentsController:self];
  </code></pre>
  <p>This is the result I get:</p>
  <p><img src="https://i.stack.imgur.com/jJHcH.png" alt="enter image description here" /></p>
  <p>Note that the image looks clipped. This is different from what it looks like if I change UIBarPositionTopAttached to UIBarPositionTop in the code:</p>
  <p><img src="https://i.stack.imgur.com/uBZ8s.png" alt="enter image description here" /></p>
  <p>The image being clipped made me think of <code>clipsToBounds</code> and I could get the search bar to display properly by adding this piece of code at the end of <code>viewDidLoad</code>:</p>
  <pre><code>for (UIView *subview in self.searchBar.subviews) {
      subview.clipsToBounds = NO;
  }
  </code></pre>
  <p>So I guess the <code>UISearchDisplayController</code> is messing with the <code>clipsToBounds</code> property of the <code>UISearchBar</code> background view. Has anyone else struggled with this? Is there a problem with my code?</p>
  <h2>Update:</h2>
  <p>Back in October 2013, besides posting this question, I also reported this using the Apple Bug Reporter tool. On January 6, 2015 (waaaay too late) I got a reply from Apple Developer Relations:</p>
  <blockquote>
  <p>There are no plans to address this based on the following:</p>
  <p>UISearchDisplayController is no longer supported. The desired
  functionality should be available with UISearchController and if not
  (or is behaving incorrectly), please file a new bug.</p>
  <p>We are now closing this report.</p>
  <p>If you have questions about the resolution, or if this is still a
  critical issue for you, then please update your bug report with that
  information.</p>
  <p>Please be sure to regularly check new Apple releases for any updates
  that might affect this issue.</p>
  </blockquote>