Search code examples
iosios7uinavigationcontrolleruinavigationbaruistatusbar

full screen background image while using uinavigationcontroller


I have an UINavigationController with UINavigationBar hidden = YES.

I want full screen bg for view that embedded in UINavigationController.

But I get only that: http://cs616618.vk.me/v616618797/1bf0d/FEdIn0Nn4x8.jpg

Is it possible to make it full screen under status bar? I achieved that with standalone view controller, but while using it in UINavigationController it becomes like on image.


Solution

  • Check that all your view controllers are correctly configured:

    The UINavigationController:

    <code>UINavigationController</code> configuration

    The rootViewController (inside the UINavigationController):

    <code>UIViewController</code> configuration

    Here's the result I get using the above configuration and an "Aspect fill" setting on the UIImageView:

    Full screen image behind status bar

    If you want to do this programmatically, try this:

    In your view controller's code:

    - (UIStatusBarStyle)preferredStatusBarStyle
    {
        return UIStatusBarStyleLightContent;
    }
    

    And where you're initializing your UINavigationController (AppDelegate, etc.):

    navController.edgesForExtendedLayout = UIRectEdgeAll;
    

    Of course, do not forget to comment or remove all lines of code that could interfere with these settings.