Skip to content
✓ValidatedDec 2025 · 3 pressure scenarios passed What's this?

SwiftUI Adaptive Layout ​

Discipline-enforcing skill for building layouts that respond to available space rather than device assumptions.

Overview ​

Covers tool selection (ViewThatFits vs AnyLayout vs onGeometryChange), size class limitations on iPad, iOS 26 free-form windows, and common anti-patterns that break in multitasking.

When to Use ​

  • "How do I make this layout work on iPad and iPhone?"
  • "Should I use GeometryReader or ViewThatFits?"
  • "My layout breaks in Split View / Stage Manager"
  • "Size classes aren't giving me what I need"
  • "Designer wants different layout for portrait vs landscape"
  • "Preparing app for iOS 26 window resizing"
  • "Should my iPhone app look like iPad in a wide window?" (iOS 27)
  • "What size classes does iPhone Duo report on its outer and inner displays?"
  • "My scroll position / selection / draft is lost when the window resizes"
  • "My form's Confirm button is clipped off-screen when the window is short"
  • "Text lines are unreadably wide in a large window"

Key Patterns ​

Tool Selection ​

I need to...Use this
Pick between 2-3 layout variantsViewThatFits
Switch H↔V with animationAnyLayout
Read container sizeonGeometryChange
Custom layout algorithmLayout protocol
Keep non-shrinkable content reachable in small windowsViewThatFits + ScrollView fallback
Cap text line length in wide windowsReadable-width frame idiom

Anti-Patterns Prevented ​

  • UIDevice.current.orientation – Reports device, not window
  • UIScreen.main.bounds – Wrong in multitasking
  • UIDevice.current.userInterfaceIdiom == .pad – iPad in 1/3 Split View is narrower than iPhone
  • Unconstrained GeometryReader — Greedy sizing breaks siblings
  • Size class as orientation proxy — iPad is .regular in both orientations
  • Injecting .regular to fake iPad on a wide iPhone window — a wide resizable iPhone window already reports .regular, and forcing it hides the tabs of a sidebar-adaptable tab view set to prefer a sidebar in narrow windows
  • Separate phone/tablet state trees — crossing the size-class boundary abandons scroll, selection, focus, and drafts; the skill maps each state type to the mechanism that survives adaptation

iOS 26 Changes ​

  • Free-form window resizing – Users can drag to resize windows anywhere
  • UIRequiresFullScreen deprecated – Apps must handle resizing
  • Menu bar on iPad – Via SwiftUI .commands
  • NavigationSplitView auto-adapts – Columns show/hide automatically

Released under the MIT License