ios7uiviewcontrolleruinavigationbarios7-statusbar

Hide statusbar with UINavigationBar barPositionTopAttached


I have rootViewController - UINavigationController. As you know UINavigationController has UINavigationBar. In iOS 7 UINavigationBar could be with barPosition topAttached. I want to hide ON/OFF statusBar by clicking on button. But I also want that UINavigationBar should be always barPositionTopAttached.

- (BOOL)prefersStatusBarHidden {
   return __statusBarHidden;
}

- (IBAction)tapShowPhotosButton:(id)sender {
    __statusBarHidden = !__statusBarHidden;
    [self setNeedsStatusBarAppearanceUpdate];
}

For now UINavigationBar changed barPosition from topAttached to top, and so on.


Solution

  • I write to technical support and get next answer:

    As stated in the documentation for , -positionForBar is called when the bar needs to know its position in its new window. It will not be called when the status bar hides or unhides. The navigation controller handles resizing the navigation bar in response to a status bar change. Unfortunately, UINavigationController does not provide any API to customize the navigation bar resizing behavior.