safeAreaLayoutGuide but under navigation and tool bars

I have a view that I would like to be kept in the "safe area" in the iPhone X, never obscured by either the corners or the notch. That requirement is easy enough to fullfill using the safeAreaLayoutGuide API. However, I want the view to extend under any navigation or toolbars that appear. Even with "Extend edges" under top bars, bottom bars, and opaque bars, the safeAreaLayoutGuide is always adjusted to not be under the bars. Is there some compromise that I'm missing that keeps the view out from under the corners and notch, but allows it to be under the bars? Is there some property on the view controller that I could use as a constant for a constraint relative to the top and bottom anchors that I am missing? It seems like all of the various insets properties on the view controller are all zero when I inspect them, but perhaps I've missed one? Thanks!

Answered by amolloy in 269294022

To answer my own question, you can get the safeAreaInsets from the window, which takes into account the corners and notch but not any bars. This feels more hacky than it ought to be, so maybe I'm still missing a better solution, but it appears to work ok.

Accepted Answer

To answer my own question, you can get the safeAreaInsets from the window, which takes into account the corners and notch but not any bars. This feels more hacky than it ought to be, so maybe I'm still missing a better solution, but it appears to work ok.

Use a scrollview and set the scroll position. scroll views I have seen go behind the notice and navigation bars.

safeAreaLayoutGuide but under navigation and tool bars
 
 
Q