Search code examples
iosiphonesplit-screen-multitasking

Preferred status bar style on iPad multitasking - split screen


I have two view controllers - the first has a UIStatusBarStyleDefault, the second has a UIStatusBarStyleLightContent.

VC1 is presenting VC2 as a modal form sheet. So when presenting in regular trait collection, VC2 is presented as UIModalPresentationFormSheet and VC1 sets the status bar to Default. But in compact trait collection, VC2 is fullscreen and sets the status bar style to Light Content.

The problem is when switching between regular to compact (full screen to form sheet) the status bar is not updating.

Full Split Screen

Trying - [self setNeedsStatusBarAppearanceUpdate]; after trait collection change did not solve the issue.

Any help will be much appreciated!


Solution

  • // This controls whether this view controller takes over control of the status bar's appearance when presented non-full screen on another view controller. Defaults to NO.
    
    @available(iOS 7.0, *)
    public var modalPresentationCapturesStatusBarAppearance: Bool
    

    Usage:

    navigationController.modalPresentationStyle = .FormSheet
    navigationController.modalPresentationCapturesStatusBarAppearance = true
    

    Once that's set the root view controller of that navigation controller can override the preferredStatusBarStyle()