Post

Yesterday, Apple updated the #SwiftUI documentation, and I found some cool and useful new additions! Here’s everything new 👇

My personal highlight, and probably the most useful addition for many of us: the new ContentMarginGuide! It lets us use the same margins Apple uses for its own content, like in Lists, instead of hard-coding values ourselves. Explore it here: exploreswiftui.com/library/view...

exploreswiftui.comContainer Content Margins | Explore SwiftUIAdds the margins of the container the view is in. Learn how to use Container Content Margins in SwiftUI with visual code examples.

0 reposts1 like

We can also read these values with GeometryReader. For example, on iPhone 18, the horizontal content margins are 16 points. On Duo in landscape, they’re 20 points on the leading edge and 0 on the trailing edge, where space is reserved on the right.

At WWDC, I told someone at Apple I’d love to have access to more of the defaults they use behind the scenes, including padding and margins. This feels like a step in the right direction, especially now that Duo is here and things are more complicated than before.

Next up: iOS 27.2 adds toolbarTitleAlignment, letting us override the automatic, context-dependent title alignment. Unfortunately, I can't get it to work on either a regular iPhone or Duo. FB25200141

The docs also include several new APIs for HomeView. Since SwiftUI can currently only be used on HomeView through widgets, Live Activities, and CarPlay, I’m curious to see how these new APIs will work in practice.