This is also described but not answered in Why does this iPhone X UIView not get safeAreaLayoutGuide?
I create a totally-new from-scratch single-view Universal iOS app and add only these three lines of code to viewDidLoad()
. I launch the iPhone X Simulator in portrait mode. Here's what I get:
let safeSize = view.safeAreaLayoutGuide.layoutFrame.size
// Returns (375.0, 812.0) — why full size?
let window = UIApplication.shared.delegate!.window!!
let safeSize2 = window.safeAreaLayoutGuide.layoutFrame.size
// Returns (375.0, 734.0) — this is what I expected.
Why does the root view controller's root view not return the expected safe area?