Preferred status bar style on iPad multitasking - split screen

跟風遠走 提交于 2019-12-07 01:24:48

问题


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.

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

Any help will be much appreciated!


回答1:


// 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()



来源:https://stackoverflow.com/questions/33736705/preferred-status-bar-style-on-ipad-multitasking-split-screen

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!