-
-
Notifications
You must be signed in to change notification settings - Fork 7
UniversalGlassContainers
UniversalGlassEffectContainer orchestrates multiple glass effects so they render as one fused surface on earlier OS releases while deferring to SwiftUI’s native GlassEffectContainer on OS 26.
The public API sits in UniversalGlassContainers.swift:
UniversalGlassEffectContainer(spacing:rendering:content:)-
.automaticor.glassrenders the native container whenever it exists. -
.materialforces the legacy renderer even on OS 26+, useful for testing or when you prefer the material aesthetic everywhere.
When the native container is unavailable, the helper swaps in FallbackGlassEffectContainerRenderer. The renderer:
- Projects every child’s anchor preference (registered by
universalGlassEffect) into concrete frames. - Groups participants by shared union keys or effect IDs so neighbouring elements “melt” into a single slab.
- Draws a
GlassEffectFallbackOverlaytwice—once as a background and once as a mask—so the merged plate perfectly clips the child content.
That setup guarantees that the fallback honours matched-geometry unions, respects per-view shapes, and keeps hit-testing consistent.
The container works hand-in-hand with:
View.universalGlassEffectUnion(id:namespace:rendering:)View.universalGlassEffectID(_:in:rendering:)View.universalGlassEffectTransition(_:)
Each helper goes straight to SwiftUI’s implementation on new OS builds and otherwise stores metadata in the environment for the fallback renderer to consume.
Need the full breakdown? See UniversalGlassEffectContainer internals for an in-depth explanation of the participant pipeline, grouping keys, and overlay drawing order.