Adapting SwiftUI layouts for iPhone Duo
Learn how to respond to changing window sizes without device or orientation checks.
02 Nov 2026 · 5 min read
Opening or closing iPhone Duo can resize an app while it is running. A layout that fits the compact outer display may therefore receive considerably more space on the inner display without the app being relaunched.
In this article, we'll explore ways to make SwiftUI layouts adapt to changing space.

Adapting list and detail navigation
A common SwiftUI interface uses a List inside a NavigationStack to navigate to a detail screen. This setup responds to size changes, but continues to display one screen at a time. On iPhone Duo's larger inner display, the list and detail could instead make use of the available space together.
For this, we can use NavigationSplitView. It presents the list and selected detail side by side when space allows and automatically collapses them into stack-based navigation in a compact environment:
struct FieldNotesView: View {@State private var selection: Specimen?var body: some View {NavigationSplitView {List(Specimen.examples, selection: $selection) { specimen inNavigationLink(value: specimen) {Label(specimen.name, systemImage: "leaf")}}.navigationTitle("Field Notes")} detail: {if let selection {SpecimenDetails(specimen: selection)} else {ContentUnavailableView("Select a specimen",systemImage: "leaf")}}}}
NavigationSplitView manages that transition while preserving the selected specimen. This also means that the layout doesn't need to know when the device folds or unfolds. It responds to the resulting presentation environment instead.
Adapting content to the available space
Beyond navigation, we can also adapt how individual views arrange and present their content. SwiftUI offers several tools for this, such as ViewThatFits or horizontalSizeClass.
Let's look at an example using horizontalSizeClass. It has two possible values: .compact and .regular. In a typical full-screen presentation, iPhones in portrait as well as the outer display of a closed iPhone Duo use .compact. The inner display of an open iPhone Duo and a full-screen iPad use .regular. The value always describes the space the app currently has, not the device it runs on.
For example, SwiftUI's Table view already adapts to these values. It displays all columns in .regular and only the first column in .compact. To keep the habitat and conservation status visible in the compact presentation, we can include them in the first column:
private struct SpecimenTable: View {@Environment(\.horizontalSizeClass) private var horizontalSizeClassvar body: some View {Table(Specimen.examples) {TableColumn("Name") { specimen inVStack(alignment: .leading) {Text(specimen.name)if horizontalSizeClass == .compact {Text("\(specimen.habitat) · \(specimen.status)").font(.caption).foregroundStyle(.secondary)}}}TableColumn("Habitat", value: \.habitat)TableColumn("Status", value: \.status)}}}
When a layout decision depends on whether content fits within a particular view, ViewThatFits can be a better choice. The article on building adaptive layouts with ViewThatFits explores that approach.
Letting SwiftUI handle changing safe areas
Safe areas work on iPhone Duo the same way as on any other device. SwiftUI provides the current safe area and keeps it up to date, so we don't have to calculate it ourselves, even when the available space changes while the app is running.
We can still let a decorative background extend to the edges with ignoresSafeArea(), while keeping text and interactive elements inside the safe area:
ZStack {Color.green.ignoresSafeArea()VStack(spacing: 16) {Text("European tree frog").font(.largeTitle)Button("Add observation") {// Add a new field note}}.padding()}
Conclusion
Preparing a SwiftUI layout for iPhone Duo doesn't require detecting the device. Standard navigation containers, size classes and safe areas allow the same view hierarchy to respond as the app moves between different presentations.



Newsletter
Like to support my work?
Say hi
Related tags
Articles with related topics
Latest articles and tips



