SwiftUI BasicsLesson 49Free preview
SwiftUI Modifiers & ViewBuilder
This lesson is part of Swift · All levels
Summary
This lesson will show you how View Modifiers and the @ViewBuilder attributes work in SwiftUI. View modifier wrapped the display component to change its style or behavior and restore a new view. @ViewBuilder is an advanced result builder that allows you to create multiple declarative child views in one closure.
Key points
- The modifier works with the chain principle (chaining) and wrapped the previous view
- The writing order of the modifier greatly affects the final layout appearance
- Custom modifier is created by adopting the 'ViewModifier' protocol
- @ViewBuilder compiles many of the child's views into one TupleView unit without syntax manual
Full lesson
Code examples and quizzes
Full lessons, code examples, and quizzes are available to subscribers. 5 questions.