I have a custom UIPresentationController and overrides frameOfPresentedViewInContainerView for a custom viewController presentation. Everything works fine, except for the status bar.
I do not want the status bar to change appearance at all – it should just stay however it looked before. Now the Apple Documentation: https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIViewController_Class/#//apple_ref/occ/instp/UIViewController/modalPresentationCapturesStatusBarAppearance says if modalPresentationStyle is not UIModalPresentationFullScreen OR modalPresentationCapturesStatusBarAppearance is NO, i should be fine and the status bar should not change.
With this code:
- (BOOL)prefersStatusBarHidden {
NSLog(
@"prefersStatusBarHidden was called %d %ld",
self.modalPresentationCapturesStatusBarAppearance,
(long)self.modalPresentationStyle
);
return YES;
}
I can see that prefersStatusBarHidden is called, even if modalPresentationCapturesStatusBarAppearance is NO (displays as 0) and modalPresentationStyle is UIModalPresentationCustom (displays as 4).
Obviously, that's the reason the status bar changes when presenting the viewController.
But why?
My thought on this is that iOS thinks that the viewController is presented in fullscreen even though it is not.
I discovered UIPresentationController's property shouldPresentInFullscreen – it returns YES by default. Returning NO doesn't help at all, so i don't understand what that property even does... It has literally no effect. The same applies to the presentationStyle property – I don't see any effect when changing it. I would have expected the presentationStyle property to be "redirected" to the viewControllers modalPresentationStyle property, but that stays at UIModalPresentationCustom, which it has to be to initiate the custom presentation in the first place.
So, my questions are: Does anybody know how to just keep the status bar as it is with a custom UIPresentationController – and can somebody explain the shouldPresentInFullscreen and presentationStyle properties?
Thank you! :)