title: UIViewController's prefersStatusBarHidden not working
body: <p>I am trying to make the status bar for one of my view controllers to be hidden (when displayed modally). When I'm presenting the view controller, the status bar is is to be hidden and then returned when dismissed.</p>
  
  <p>I have added the following code to the presented view controller</p>
  
  <pre><code>- (BOOL)prefersStatusBarHidden
  {
      return YES;
  }
  </code></pre>
  
  <p>I have also set the keys in the Info.plist file to the following:</p>
  
  <pre><code>&lt;key&gt;UIViewControllerBasedStatusBarAppearance&lt;/key&gt;
  &lt;true/&gt;
  </code></pre>
  
  <p>From my understanding this should be all that is required to make this work. </p>
  
  <p>I am also using a custom Animation Controller to do the presenting which conforms to the <code>UIViewControllerAnimatedTransitioning</code> protocol. In the <code>animateTransition:</code> implementation I have tried to manually call <code>prefersStatusBarHidden</code>, followed by <code>setNeedsStatusBarAppearanceUpdate</code> to ensure the call is being made, but the status bar remains.</p>
  
  <p>Any ideas why this is happening would be appreciated. I have searched StackOverflow, but it appears no one has had this issue, all accepted answers refer to calling <code>setNeedsStatusBarAppearanceUpdate</code>, which I am already doing.</p>
  
  <p><strong>EDIT</strong> - The code below now seems to <strong><em>WORK</em></strong> as desired </p>
  
  <pre><code>- (void)animateTransition:(id &lt;UIViewControllerContextTransitioning&gt;)transitionContext
  {
      if (self.isPresenting) {
          UIView *containerView = [transitionContext containerView];
  
          UIViewController *fromViewController = [transitionContext viewControllerForKey:UITransitionContextFromViewControllerKey];
          UIViewController *toViewController = [transitionContext viewControllerForKey:UITransitionContextToViewControllerKey];
  
          toViewController.view.frame = containerView.frame;
  
          [containerView addSubview:toViewController.view];
  
          // Ask the presented controller whether to display the status bar
          [toViewController setNeedsStatusBarAppearanceUpdate];
  
          [UIView animateWithDuration:1.0f delay:0.0f options:UIViewAnimationOptionCurveEaseIn animations:^{
              toViewController.view.alpha = 1.0f;
              fromViewController.view.alpha = 0.0f;
          } completion:^(BOOL finished) {
              [transitionContext completeTransition:YES];
          }];
      }
      else {
          // do the reverse
          UIViewController *fromViewController = [transitionContext viewControllerForKey:UITransitionContextFromViewControllerKey];
          UIViewController *toViewController = [transitionContext viewControllerForKey:UITransitionContextToViewControllerKey];
  
          [UIView animateWithDuration:1.0f delay:0.0f options:UIViewAnimationOptionCurveEaseIn animations:^{
              toViewController.view.alpha = 1.0f;
              fromViewController.view.alpha = 0.0f;
          } completion:^(BOOL finished) {
              [transitionContext completeTransition:YES];
              // Once dismissed - ask the presenting controller if the status bar should be presented
              [toViewController setNeedsStatusBarAppearanceUpdate];
          }];
      }
  }
  
  ....
  
  // PresentingController.m
  - (BOOL)prefersStatusBarHidden
  {
      if (self.presentedViewController) {
          return YES;
      }
      return NO;
  }
  
  // PresentedController.m
  - (BOOL)prefersStatusBarHidden
  {
      return YES;
  }
  </code></pre>