What are safe area and layout margins?
Safe area
The safe area is the part of a view not covered by system UI: the status bar, Dynamic Island, home indicator, navigation bar, tab bar, as well as the keyboard on iPad and the "ears" on external displays. Content that must be visible and tappable is pinned to view.safeAreaLayoutGuide; backgrounds, images and scrollable content go to the view's edges so they extend under the bars.
- The value comes from the window and controller:
safeAreaInsetson the view,additionalSafeAreaInsetson the controller — to extend the safe area for your own panel (e.g. a custom player at the bottom). safeAreaInsetsDidChange()is called on change (rotation, a bar appearing).keyboardLayoutGuide(iOS 15) — a separate guide that follows the keyboard; replaces manualkeyboardWillShownotifications.- The SwiftUI counterparts are
.safeAreaInset(edge:)and.ignoresSafeArea().
The rest of this answer, with code and interview follow-ups, is in the DevPrep app.
Read the full answer in DevPrep