title: How to change PreferredStatusBarStyle programmatically
body: <p>I'd like to change the color of status bar from white to black by press button, <strong>programmatically</strong> only in a single-ViewController</p>
  
  <p>This is the code:</p>
  
  <pre><code>- (UIStatusBarStyle)preferredStatusBarStyle {
      NSLog(@"PreferredStatusBarStyle");
      if(nav_bar.alpha==1)
      {
          NSLog(@"-&gt;UIStatusBarStyleBlackOpaque");
          return UIStatusBarStyleBlackOpaque;
      }
      else
      {
          NSLog(@"-&gt;UIStatusBarStyleLightContent");
          return UIStatusBarStyleLightContent;
      }}
  </code></pre>
  
  <p>then When I press a button action is:</p>
  
  <pre><code>[self setNeedsStatusBarAppearanceUpdate];
  </code></pre>
  
  <p><strong>But</strong> this doesn't work!</p>
  
  <p>When I press the button log write the correct status according to navbar.alpha, but statusbar text color remain UIStatusBarStyleBlackOpaque like when view appear.</p>