Our session notes, design notes and Group Lab Q&A explain why the insets differ. This post is the code: which APIs to read, which maths to delete, and how to test it.
Paragraphs that start with Our reading or Our suggestion are ours, not Apple's words.
Why the sides differ
In the "Respect safe areas" chapter (6:06) of the Tech Talk Prepare your app for iPhone Duo, Apple says: "Keep in mind that safe areas are often asymmetric. This is especially true on iPhone Duo. For example, vertical buttons can appear on the left side in landscape and Split View multitasking. As such, avoid assuming that insets on opposite sides are equal. Instead, write code that handles each side independently."
Just before that, at the end of the 5:01 chapter and the start of 6:06, the talk explains where the extra inset comes from: "Navigation bars, toolbars, and tab bars lay out outside the safe area. … Horizontal bars provide top and bottom insets, while vertical bars provide leading and trailing insets." Our vertical bars post covers when bars turn vertical.
Our reading: on a classic iPhone in portrait, side insets were usually zero, so code that only thought about the top and bottom never failed. On the Duo, a vertical bar adds an inset on one side only, so that code now breaks.
The bug: mirrored inset maths
This is Apple's own before-and-after from the talk's code at 7:30, wrapped to fit the page:
// Avoid assuming insets on
// opposite sides are equal
let width = view.bounds.width
- view.safeAreaInsets.left * 2
// Handle each side independently
let width = view.bounds
.inset(by: view.safeAreaInsets)
.width
Our reading: the same bug hides in other shapes. Look for an inset doubled (* 2), one side copied to the other, max(left, right) used for both sides, and content centred with bounds.midX when it should be centred in the safe area. This search finds most of them:
grep -rnE \
"safeAreaInsets\.(left|right)" \
--include="*.swift" .
Check each hit: if it reads one side and uses the result for both, rewrite it with inset(by:) or the layout guide below.
Foreground inside, background outside
The talk's rule: "place foreground elements like interactive controls within the safe area. For SwiftUI, your content is placed within the safe area by default. For UIKit, if you are laying out views manually, reference the view's safe area insets, or use Auto Layout to constrain the views to the safe area layout guide. Allow background elements such as full-bleed artwork to fill the available space … For SwiftUI, use ignoresSafeArea. For UIKit, use the view's bounds."
UIKit, manual frames (6:52, 7:07)
The two frame lines are the talk's code. The method around them and the comments are ours.
override func viewDidLayoutSubviews() {
super.viewDidLayoutSubviews()
// Foreground: inside the safe area
foreground.frame = view.bounds
.inset(by: view.safeAreaInsets)
// Background: full bleed
backgroundView.frame = view.bounds
}
UIKit, Auto Layout
let safe = view.safeAreaLayoutGuide
NSLayoutConstraint.activate([
controls.leadingAnchor.constraint(
equalTo: safe.leadingAnchor),
controls.trailingAnchor.constraint(
equalTo: safe.trailingAnchor),
artwork.leadingAnchor.constraint(
equalTo: view.leadingAnchor),
artwork.trailingAnchor.constraint(
equalTo: view.trailingAnchor)
])
SwiftUI
ZStack {
Artwork()
.ignoresSafeArea()
// Stays in the safe area by default
Controls()
}
Apple's documentation for ignoresSafeArea(_:edges:) warns: "If your view has a fixed size, the alignment of the view may not be what you expect."
Our suggestion: apply it to the background only, never to the stack that holds your controls.
Layout margins are asymmetric too
The talk: "As with safe areas, layout margins are also asymmetric. This lets your foreground content get closer to vertical buttons and the status bar, while preserving the margin on the opposite side."
directionalLayoutMargins: "The system applies leading and trailing margins appropriately to the left or right margins based on the current layout direction." For a view controller's root view, "the default value of this property reflects the system minimum margins and safe area insets."insetsLayoutMarginsFromSafeArea: whentrue, "any margins that are outside the safe area are automatically modified to fall within the safe area boundary. The default value of this property istrue."
Our reading: if you pin text to layoutMarginsGuide and leave these defaults alone, you get the Duo's uneven margins for free. The usual way to lose them is to overwrite the margins with equal values on both sides, or to set insetsLayoutMarginsFromSafeArea to false.
Our suggestion: prefer leading and trailing (anchors, directionalLayoutMargins, SwiftUI's .leading/.trailing) over left and right. safeAreaInsets itself is a UIEdgeInsets with physical left and right; that is fine for frame maths like inset(by:), which uses both sides as they are.
When to read the insets
Apple's documentation for safeAreaInsets: "If the view is not currently installed in a view hierarchy, or is not yet visible onscreen, the edge insets in this property are 0."
Our reading: so a value read in init or viewDidLoad is zero, and a value you store goes stale when a bar moves to the other side.
UIKit tells you when they change. viewSafeAreaInsetsDidChange(): "UIKit updates the safe area in response to size changes to system bars or when you modify the additional safe area insets of your view controller. UIKit also calls this method immediately before your view appears onscreen." Views get safeAreaInsetsDidChange().
override func
viewSafeAreaInsetsDidChange() {
super.viewSafeAreaInsetsDidChange()
// Keep the maths in one place:
// viewDidLayoutSubviews
view.setNeedsLayout()
}
Our suggestion: do not cache insets in properties. Read them in the layout method each time, and use the change callback only to ask for a new layout pass.
Scroll views: adjustedContentInset is "the insets derived from the content insets and the safe area of the scroll view". Its documentation says contentInsetAdjustmentBehavior "determines whether the safe area insets are included in the adjustment", and that the safe area insets "are then added to the values in the contentInset property".
Our reading: if your code also adds the safe area to contentInset by hand, the inset is counted twice. Remove one of the two.
Your own bars and panels
The talk's summary starts with "use standard bars for UI that automatically adapts to the safe area". If you draw your own side panel or bar, tell the content underneath about it:
- UIKit containers: Apple's article Positioning content relative to the safe area says to extend a child's safe area with
additionalSafeAreaInsets, and to do it inviewDidAppear(_:)"because the safe area insets for a view aren’t accurate until the view is added to a view hierarchy." - SwiftUI:
safeAreaInset(edge:with a horizontal edge "displays content beside the modified view, making space for the content view by horizontally insetting the modified view."alignment: spacing: content:) safeAreaPadding(_:_:)adds a fixed amount to the safe area instead.
ScrollView {
Feed()
}
.safeAreaInset(edge: .leading,
spacing: 0) {
Sidebar()
}
For custom bars that should use the space outside the safe area without hitting the camera or the fold, iOS 27.1 adds reserved regions. Apple's documentation lists GeometryProxy in SwiftUI, returning [ReservedRegion], and UIView in UIKit (Objective-C: reservedRegionsOfKind:options:). Each region's frame is in your view's own coordinates and "already includes the region’s margins". Our Strike a Pose notes cover the two kinds, occlusion and division.
Test both sides in Split View
Apple's steps from the talk, using Device Hub in Xcode:
- Preview your app on the inner display.
- Drag your app by the home indicator at the bottom to one side of the screen, and drop it in the area that appears.
- Then drag it to the other side. "Vertically laid-out content can appear on either side of your app."
Our suggestion: also rotate to landscape on both displays, since the talk names landscape as the other case where vertical buttons move to the left. Our Simulator post covers Device Hub setup, and our viewport simulator shows the display sizes.
Checklist
- No inset doubled, mirrored or taken as
max(left, right) - Foreground frames from
boundsor.inset(by: safeAreaInsets) safeAreaLayoutGuide - Background views on
bounds; in SwiftUI,.ignoresSafeArea()on the background only - Layout margins left at their defaults, so they stay asymmetric
- Insets read during layout, never cached or read in
viewDidLoad - Scroll views not adding the safe area to
contentInsetby hand - Custom bars and panels reported with
additionalSafeAreaInsetsorsafeAreaInset - Tested in Split View on both sides, and in landscape
safeAreaInsets, safeAreaLayoutGuide, directionalLayoutMargins, insetsLayoutMarginsFromSafeArea, viewSafeAreaInsetsDidChange(), adjustedContentInset, ignoresSafeArea(_:edges:), safeAreaInset, safeAreaPadding, ReservedRegion, UIView.ReservedRegion and the article "Positioning content relative to the safe area". All were read on 19 November 2026. The Auto Layout, SwiftUI and callback samples, the method wrapping the 6:52 and 7:07 lines, and the grep are ours, built on the APIs those sources name. Apple has not reviewed this page.