An iOS app that investigates effects of using different approaches in building view hierarchies and state managment on views redraws:
- Extraction of subviews into a separate structs and view modifying methods into view modifiers
- Usage of
@ViewBuilder
and its underlying_ConditionalContent
view - Passing values down the hierarchy through @Binding and through @Environment
.id(_:)
modifier- Conforming your views to
Equatable
protocol and usage of.equatable()
modifier - Comparison of
ObservableObject
and@Observable
approaches
By Eduard Jeleński, 2024
SwiftUI Views Redrawing Patterns app on GitHub
- Open the project in Xcode.
- Run the app on the iOS simulator, an iOS device.
- Click through the list of examples, conduct the experiment and explore the explanation down below.
Requires iOS 17.