本文介绍了iPad多任务处理的首选状态栏样式 - 分屏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两个视图控制器 - 第一个有 UIStatusBarStyleDefault ,第二个有 UIStatusBarStyleLightContent

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

VC1将VC2作为模态表格提交。因此,当呈现常规特征集时,VC2呈现为 UIModalPresentationFormSheet ,VC1将状态栏设置为默认
但是在紧凑的特征收集中,VC2是全屏的,并将状态栏样式设置为轻量级内容

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.

尝试 -
[self setNeedsStatusBarAppearanceUpdate];特征收集更改后
没有解决问题。

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

任何帮助都将不胜感激!

Any help will be much appreciated!

推荐答案

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

用法:

navigationController.modalPresentationStyle = .FormSheet
navigationController.modalPresentationCapturesStatusBarAppearance = true

一旦设置了该导航控制器的根视图控制器就可以覆盖preferredStatusBarStyle()

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

这篇关于iPad多任务处理的首选状态栏样式 - 分屏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-24 16:49