好的,被告知这是可能的,我尝试在主视图顶部放置一个视图并将其 y 坐标设置为 -20。然后我向西到 Info.plist 并设置Status bar style
为Transparent black style (alpha of 0.5)
. 我放置的视图在状态栏下方可见。

这只发生在运行时;在 Interface Buider 中,模拟的半透明状态栏是灰色但不透明的。
编辑:如果你想将视图控制器的主视图移动到这个空间中,可以在viewWillAppear
. (如果您尝试在 期间移动它viewDidLoad
,它会在之后移回。)
- (void)viewWillAppear:(BOOL)animated;
{
[super viewWillAppear:animated];
// Move the main view upwards if it isn't already there.
CGRect frame = [[self view] frame];
frame.size.height += frame.origin.y;
frame.origin.y = 0;
[[self view] setFrame:frame];
}
但是,它在旋转后被移回,如果我对UITableView
.
这是斯威夫特版本。似乎工作。拍摄这些 App Store 屏幕截图的好解决方案(除了更改 info.plist 之外。
覆盖 func viewWillAppear(动画:布尔){
super.viewWillAppear(animated)
// Move the main view upwards if it isn't already there.
var frame: CGRect = self.view.frame
frame.size.height += frame.origin.y
frame.origin.y = 0
self.view.frame = frame
}