Creating and Combining Views

Overview

The lesson you are about to undertake comes directly from the big Apple itself (the company, not the city). Some of Apple’s tutorials can be hard to follow because they seem to be oriented more towards professional developers with the assumption that whoever is using the tutorial has a lot of prior knowledge. This tutorial is an exception because it is well-written and well-structured for early-stage SwiftUI developers.

Some parts of this tutorial will likely be fundamental and familiar to you and will mainly serve as reiteration and practice. The tutorial will also introduce some new concepts and present a different perspective from the tutorials we have followed up to this point. In particular, their explanation about how SwiftUI view files are set up into two structs: one that serves as a ‘view’ for content and layout, and another that handles the preview for the other struct offers a helpful explanation.

Click below to start the lesson:

https://developer.apple.com/tutorials/swiftui/creating-and-combining-views

Key Takeaways

  • Every SwiftUI view file contains two structs: one declares the layout and logic, the other provides the Xcode canvas preview.
  • Views are composed by nesting — SwiftUI builds complex UIs from many small, single-purpose views rather than one large monolithic view.
  • Every modifier returns a new, modified copy of the view — the chain is immutable, and the order of modifiers can change the visual result.
  • Apple’s tutorial format is more step-by-step than the textbook and is well-suited for early-stage developers — follow it sequentially without skipping.