Introduction

Heads up... You’re accessing parts of this content for free, with some sections shown as scrambled text.

Heads up... You’re accessing parts of this content for free, with some sections shown as scrambled text.

Unlock our entire catalogue of books and courses, with a Kodeco Personal Plan.

Unlock now

SwiftUI represents an exciting new paradigm for user interface design. SwiftUI relies upon the idea of composing larger views by assembling smaller ones. Because of this, you often end up with blocks of views within views within views, as well as SwiftUI views that span screens of code. Splitting components into separate views makes your code cleaner.

In addition, splitting a view into smaller components makes it easier to reuse that view within a project as well as in other projects. In this lesson, you’ll start with a simple view and expand it using smaller views. You’ll then see how using view builders, generics, and key paths can turn your views into reusable, flexible puzzle pieces to assemble however you like.

By the end of this lesson, you’ll be able to:

  • Leverage SwiftUI’s principle of modular design to build a complex view from smaller, simpler ones.
  • Use ViewBuilder to create a reusable view.
  • Use generics and key paths to encapsulate a view for reuse anywhere.

Time to get started!

See forum comments
Download course materials from Github
Previous: Quiz: Mastering SwiftUI Animations Next: Building Reusable Views