Conclusion

SwiftUI was built for developers to create small and reusable views. It has tools and flexibility that allows you to build simple yet powerful views — either by composing smaller views into a bigger custom view, or by creating a view modifier.

In this lesson you learned:

  • That code duplication can become a problem, and how the famous software engineering principle DRY can help you avoid those problems.
  • How to create custom SwiftUI Views, and why that’s important for code maintainability and readability.
  • You also learned about View Modifiers and how to create a custom view modifier to modify views.

If you want to learn more about reusable views, and a more complex way of composing views, check out ViewBuilder Tutorial: Creating Reusable SwiftUI Views to learn about View Builders and how to use them to pass views as a parameter to another view.

In the next lesson, you’ll continue to work on RGB Picker, and you’ll learn about the different layouts SwiftUI has and how to solve common issues when your app supports landscape mode.

See forum comments
Download course materials from Github
Previous: Demo 2 Next: Quiz: Creating Custom SwiftUI Views