Introduction
Recap
In previous lessons, you learned the basics of SwiftUI and how the framework works across Apple’s platforms — iOS, iPadOS, and even macOS. You learned that SwiftUI has a declarative syntax and how this differs from UIKit. You also started working on a new app, RGB Picker, and you learned about different controls and views.
And while SwiftUI offers a plethora of built-in views that are the cornerstones of the framework, like Slider
, Text
, and Button
, it also allows developers to create their own custom views. Much like its predecessor, UIKit, SwiftUI allows you to create views that are a composition of those basic built-in views so you can create your own views that can be reused in many places in your app.
In this lesson, you’ll:
- Learn about Custom SwiftUI Views and how to declare and create new views.
- Design Reusable SwiftUI Views that change depending on their parameters and can be reused in many places in your app.
- Create a View Modifier to modify and style views throughout your code.
Additionally, you’ll refactor RGB Picker to use your new custom views and view modifier — reducing code duplication.