Custom presentation controllers can’t change the status bar view controller

Originator:douglashill
Number:rdar://35985410 Date Originated:12-Dec-2017 11:16 am
Status:Open Resolved:
Product:iOS + SDK Product Version:Xcode 9.2 (9C40b)
Classification:Other Bug Reproducible:Always
 
Summary:
When a view controller is presented, it may or may not become the view controller specifying the appearance of the status bar. There is no public API to control this on UIPresentationController, so custom presentation controllers are stuck not being able to change the status bar view controller.

Instead, we have to violate separation of concerns and instead ensure `modalPresentationCapturesStatusBarAppearance` is set on any view controller presented with that presentation controller.

Steps to Reproduce:
1. Create a subclass of UIPresentationController
2. Look for API to make view controllers presented with that presentation controller always become the status bar view controller

Expected Results:
It should be possible to create a custom presentation controller that always makes the presented view controller control the status bar. The view controllers being presented should not be involved in this decision.

This would be useful for any presentation controller that makes the presented view fill the screen, or at least the top part of it.

It would make sense to me if the private shouldPresentedViewControllerControlStatusBarAppearance was replaced by a public property on UIPresentationController returning an enum with three possible values:

• Always change status bar view controller, ignoring modalPresentationCapturesStatusBarAppearance (presented view is opaque, covering the top of the screen — e.g. full screen)
• Never change status bar view controller, ignoring modalPresentationCapturesStatusBarAppearance (presented view does not cover the top of the screen — e.g. popover)
• Defer to the presented view controller’s modalPresentationCapturesStatusBarAppearance (presented view covers the top of the screen and may be transparent — e.g. over full screen)

Actual Results:
No public API for this.

There is private API on UIPresentationController to do this (shouldPresentedViewControllerControlStatusBarAppearance), and it is used by the built-in presentation controllers.

If the presentation style puts the presented view controller at the top of the screen, we have to violate separation of concerns and instead ensure modalPresentationCapturesStatusBarAppearance is set on any view controller presented with that presentation controller.

Version:
Xcode 9.2 (9C40b)

Notes:
This also means if using a plain UIPresentationController the presented view fills the container view, but it does not make the presented view controller fill the status bar. This appears to be the cause of radar 35966854, so it looks like this problem even trips up UIKit engineers.

I’ve attached a trivial sample showing the case of a plain UIPresentationController. It shows a dark view controller after 2 seconds and you can see the dark view controller is not able to change the status bar.

It used to be the case (I believe believe prior to iOS 10) that custom presentation controllers were forced to change the  status bar view controller (radar 22565293). The current situation is somewhat better, but the root of the problem (this needs to be publicly customisable) has not been addressed.

Comments


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!