提交 16b2964f 编写于 作者: C Chris Bracken 提交者: GitHub

Handle double-height status bar on iOS (#3357)

* Handle double-height status bar on iOS

In certain cases, iOS displays a double-height status bar (e.g., when an
application is using device location or while in a call). In such cases,
iOS offsets the app view origin by 20px, reduces view height by 20px,
then overlays a 40px opaque status bar: 20px covering the newly opened
20px gap at the top of the screen, 20px covering the top 20px of the
view, which had previously been under the standard-sized status bar.

Flutter previously set top padding to the height of the status bar,
which resulted in 40px padding with a double-sized status bar. However,
the padding should match the portion of the status bar overlapping the
view, which is 20px.

Note that the final case is the one in which no status bar is shown and
padding should be zero.

* Only apply status bar padding on root views
上级 0206d20d
......@@ -342,14 +342,22 @@ static inline PointerChangeMapperPhase PointerChangePhaseFromUITouchPhase(
}
- (void)viewDidLayoutSubviews {
CGSize size = self.view.bounds.size;
CGSize viewSize = self.view.bounds.size;
CGFloat statusBarPadding = 0.0;
CGFloat scale = [UIScreen mainScreen].scale;
if (self.parentViewController == nil) {
// If we're the root view controller, apply any padding necessary for the
// status bar. If we're not the root view controller, assume the root view
// controller has dealt with it.
CGSize sbSize = [UIApplication sharedApplication].statusBarFrame.size;
statusBarPadding = sbSize.height - self.view.frame.origin.y;
}
_viewportMetrics.device_pixel_ratio = scale;
_viewportMetrics.physical_width = size.width * scale;
_viewportMetrics.physical_height = size.height * scale;
_viewportMetrics.physical_padding_top =
[UIApplication sharedApplication].statusBarFrame.size.height * scale;
_viewportMetrics.physical_width = viewSize.width * scale;
_viewportMetrics.physical_height = viewSize.height * scale;
_viewportMetrics.physical_padding_top = statusBarPadding * scale;
[self updateViewportMetrics];
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册