Custom Styleable Containers in SwiftUI
summary
Claims two simple tricks let developers build fully styleable SwiftUI containers: use subviews collection to get a resilient array of child views (handles conditionals and ForEach) and read child preferences with container values so children send tags and labels upward. Uses iOS 18 APIs (available to ~97% of users), makes styles work with property wrappers by conforming the style to dynamic property, and demonstrates a working custom tab view (~150 lines) with grid, menu and overflow behaviors, no AnyView hacks or custom result builders.
AI-written summary · about
chapters (14)
- 0:00Introduction by host
- 1:24Speaker introduction
- 2:28What is a container in SwiftUI
- 3:35Challenges of custom containers
- 6:50iOS 18 container APIs
- 9:02Using SubviewsCollection
- 10:28Container values explained
- 13:21Styling containers
- 15:09Dynamic property protocol
- 18:44Demo setup
- 20:32MyTabView implementation
- 23:49Configuration and styling
- 25:15Demo of custom tab view
- 27:43Summary and resources
related talks
34m_VariadicView: Highlighting the Hidden Powers of Containers
36mSwiftUI Everywhere
39mBuilding REUSABLE SwiftUI components
33mCombining SwiftUI and UIKit, AppClips and Widgets
31mThe Swift Behind SwiftUI
30mEvolving Existing Projects With SwiftUI
26mJetpack Compose and SwiftUI: A side-by-side comparison
27mA 100% SwiftUI App
