### Apply Regular Glass Effect with Tint Source: https://github.com/aeastr/universalglass/blob/main/docs/Effects.md Quick start example demonstrating how to apply a regular glass effect with a purple tint to a Text view using UniversalGlass. ```swift import UniversalGlass Text("Hello") .universalGlassEffect(.regular.tint(.purple)) ``` -------------------------------- ### Quick Start with UniversalGlass Backports Source: https://github.com/aeastr/universalglass/blob/main/docs/Backports.md Demonstrates how to use the backported glass modifiers and styles in SwiftUI. Ensure both UniversalGlass and UniversalGlassBackports are imported. ```swift import UniversalGlass import UniversalGlassBackports Button("RSVP") {} \ .buttonStyle(.glassProminent) CardView() .glassEffect(.regular.tint(.mint)) ``` -------------------------------- ### Apply Custom Shadow to Glass Effect Source: https://github.com/aeastr/universalglass/blob/main/docs/Effects.md Example of applying a custom shadow configuration to a glass effect. ```swift // Custom shadow .universalGlassEffect( .regular.shadow(UniversalGlassShadow(color: .red, radius: 12)) ) ``` -------------------------------- ### Apply Default Shadow to Glass Effect Source: https://github.com/aeastr/universalglass/blob/main/docs/Effects.md Example of applying the default shadow preset to a glass effect. ```swift // Default shadow (automatically applied) .universalGlassEffect(.regular.shadow(.default)) ``` -------------------------------- ### Interop with SwiftUI Button Styles Source: https://github.com/aeastr/universalglass/wiki/UniversalGlassButtonStyles Example of using UniversalGlass styles alongside other SwiftUI button styles like .borderedProminent. ```swift .buttonStyle(.universalGlass()) ``` -------------------------------- ### Override Fallback Material and Tint for Glass Effect Source: https://github.com/aeastr/universalglass/blob/main/docs/Effects.md Example of overriding both the fallback material and tint for a glass effect, useful for precise control on older systems. ```swift // Custom fallback material .universalGlassEffect(.regular.fallback(material: .thin)) ``` ```swift // Custom fallback tint .universalGlassEffect(.thick.fallback(material: .regular, tint: .blue.opacity(0.2))) ``` -------------------------------- ### Force Material Rendering Mode Source: https://github.com/aeastr/universalglass/blob/main/docs/Effects.md Example of forcing all glass effects within a view hierarchy to use the material fallback rendering mode, useful for testing. ```swift // Force material fallback (useful for testing) MyApp() .universalGlassRenderingMode(.material) ``` -------------------------------- ### Adding UniversalGlass Backports to Swift Package Source: https://github.com/aeastr/universalglass/blob/main/docs/Backports.md Shows how to include the UniversalGlass and UniversalGlassBackports products in your Swift Package dependencies. This setup allows your application target to use the backported APIs. ```swift .package(url: "https://github.com/Aeastr/UniversalGlass", from: "1.0.0"), .target( name: "YourApp", dependencies: [ .product(name: "UniversalGlass", package: "UniversalGlass"), .product(name: "UniversalGlassBackports", package: "UniversalGlass"), ] ) ``` -------------------------------- ### Quick Start: UniversalGlassEffectContainer Source: https://github.com/aeastr/universalglass/blob/main/docs/Containers.md Use UniversalGlassEffectContainer to group multiple views with glass effects. Apply .universalGlassEffect() and .universalGlassEffectUnion() to child views for unified rendering. ```swift @Namespace private var ns UniversalGlassEffectContainer { HStack { AvatarView() .universalGlassEffect() .universalGlassEffectUnion(id: "profile", namespace: ns) DetailsView() .universalGlassEffect() .universalGlassEffectUnion(id: "profile", namespace: ns) } } ``` -------------------------------- ### Using UniversalGlass Button Styles Source: https://github.com/aeastr/universalglass/wiki/UniversalGlassButtonStyles Demonstrates how to apply UniversalGlass button styles using static helpers and shorthand modifiers. ```swift PrimitiveButtonStyle.universalGlass(rendering:) PrimitiveButtonStyle.universalGlassProminent(rendering:) ``` ```swift View.universalGlassButtonStyle(isProminent:rendering:) View.universalGlassProminentButtonStyle(rendering:) ``` -------------------------------- ### UniversalGlassEffectContainer Entry Point Source: https://github.com/aeastr/universalglass/blob/main/docs/Containers.md The entry point for UniversalGlassEffectContainer allows specifying rendering modes. Use .automatic or .glass for native rendering, or .material to force the legacy renderer. ```swift UniversalGlassEffectContainer(spacing:rendering:content:) ``` -------------------------------- ### Apply Custom Transitions to Glass Effects Source: https://github.com/aeastr/universalglass/blob/main/docs/Effects.md Illustrates applying different transition types to views with glass effects, including custom blur transitions. ```swift VStack { Text("Slide Transition") .universalGlassEffect() .universalGlassTransition(.slide) Text("Scale Transition") .universalGlassEffect() .universalGlassTransition(.scale) Text("Blur Without Scale") .universalGlassEffect() .universalGlassTransition(.universalGlassMaterialBlurWithoutScale) } ``` -------------------------------- ### Import UniversalGlass Source: https://github.com/aeastr/universalglass/blob/main/README.md Import the UniversalGlass module to use its features. ```swift import UniversalGlass ``` -------------------------------- ### Force Glass Rendering Mode Source: https://github.com/aeastr/universalglass/blob/main/docs/Effects.md Demonstrates forcing all glass effects to use the native glass rendering mode when available. ```swift // Force glass when available MyApp() .universalGlassRenderingMode(.glass) ``` -------------------------------- ### UniversalGlass Rendering Options Source: https://github.com/aeastr/universalglass/wiki/UniversalGlassButtonStyles Illustrates the different rendering options available for UniversalGlass styles, including automatic, glass, and material fallbacks. ```swift UniversalGlassRendering.automatic UniversalGlassRendering.glass UniversalGlassRendering.material ``` -------------------------------- ### Implement Custom Blur Transitions Source: https://context7.com/aeastr/universalglass/llms.txt Utilize `.transition(.universalGlassMaterialBlur)` for standard blur effects, `.universalGlassMaterialBlurWithoutScale` to disable scaling, or `.universalGlassMaterialFallbackBlur` for asymmetric animations. Custom intensity and scale can be set. ```swift import SwiftUI import UniversalGlass struct BlurTransitionExamples: View { @State private var showContent = true var body: some View { VStack(spacing: 24) { if showContent { // Standard material blur transition Text("Standard Blur") .padding() .universalGlassEffect() .transition(.universalGlassMaterialBlur) // Blur without scaling Text("Blur Only (No Scale)") .padding() .universalGlassEffect() .transition(.universalGlassMaterialBlurWithoutScale) // Asymmetric fallback blur (different insert/remove) Text("Fallback Blur") .padding() .universalGlassEffect() .transition(.universalGlassMaterialFallbackBlur) // Custom intensity and scale Text("Custom Parameters") .padding() .universalGlassEffect() .transition(.universalGlassMaterialBlur(intensity: 10, scale: 0.85)) } Button(showContent ? "Hide" : "Show") { withAnimation(.spring(duration: 0.45)) { showContent.toggle() } } .buttonStyle(.universalGlass()) } } } ``` -------------------------------- ### Apply Backported Glass Button Style Source: https://github.com/aeastr/universalglass/blob/main/README.md Use the backported `.glassProminent` button style after importing UniversalGlassBackports. ```swift import UniversalGlassBackports Button("RSVP") {} .buttonStyle(.glassProminent) ``` -------------------------------- ### UniversalGlass Transitions Source: https://github.com/aeastr/universalglass/blob/main/docs/Effects.md API for customizing transitions applied to views with UniversalGlass effects. ```APIDOC ## Transition Modifier for UniversalGlass Effects ### Description This modifier allows you to specify custom transitions for views that have UniversalGlass effects applied. It mirrors SwiftUI's transition APIs and provides fallback behavior for older systems. ### Method - `universalGlassEffectTransition(_:)` ### Parameters - `transition` (AnyTransition) - The transition to apply. Can be standard SwiftUI transitions or custom UniversalGlass transitions like `.universalGlassMaterialBlurWithoutScale`. ### Request Example ```swift VStack { Text("Slide Transition") .universalGlassEffect() .universalGlassTransition(.slide) Text("Scale Transition") .universalGlassEffect() .universalGlassTransition(.scale) Text("Blur Without Scale") .universalGlassEffect() .universalGlassTransition(.universalGlassMaterialBlurWithoutScale) } ``` ### Response - The view will animate in and out using the specified transition. ``` -------------------------------- ### Import UniversalGlass and UniversalGlassBackports Source: https://github.com/aeastr/universalglass/wiki/Backports Import both UniversalGlass and UniversalGlassBackports modules where you intend to use the back-deployed API surface. UniversalGlass handles the rendering logic, while UniversalGlassBackports provides the Apple-style symbols for older OS versions. ```swift import UniversalGlass import UniversalGlassBackports ``` -------------------------------- ### Customize Fallback Material and Shadow Source: https://context7.com/aeastr/universalglass/llms.txt Override the material and shadow used on older OS versions when native glass is unavailable. Use `.fallback(material: .thin)` for custom materials and `.shadow(UniversalGlassShadow(...))` for custom shadows. ```swift import SwiftUI import UniversalGlass struct FallbackCustomizationExamples: View { var body: some View { VStack(spacing: 24) { // Custom fallback material Text("Custom Material Fallback") .padding() .universalGlassEffect(.regular.fallback(material: .thin)) // Custom fallback material with tint Text("Tinted Material Fallback") .padding() .universalGlassEffect( .thick.fallback(material: .regular, tint: .blue.opacity(0.2)) ) // Remove fallback tint Text("No Fallback Tint") .padding() .universalGlassEffect(.thick.fallback(tint: nil)) // Custom shadow Text("Custom Shadow") .padding() .universalGlassEffect( .regular.shadow(UniversalGlassShadow(color: .red, radius: 12)) ) // No shadow Text("No Shadow") .padding() .universalGlassEffect(.regular.shadow(.none)) // Default shadow (8pt radius, 0.04 opacity black) Text("Default Shadow") .padding() .universalGlassEffect(.regular.shadow(.default)) } } } ``` -------------------------------- ### Chaining Configuration Modifiers Source: https://github.com/aeastr/universalglass/wiki/UniversalGlassEffects All configuration methods for Universal Glass effects are fully chainable, allowing for complex customization in a single modifier chain. ```swift Text("Fully Customized") .universalGlassEffect( .ultraThick .fallback(material: .thin, tint: .cyan.opacity(0.3)) .shadow(UniversalGlassShadow(color: .blue, radius: 16)) .tint(.purple) .interactive() ) .universalGlassTransition(.opacity) ``` -------------------------------- ### Apply Glass Effect Transitions Source: https://context7.com/aeastr/universalglass/llms.txt Use `.universalGlassEffectTransition()` with predefined styles like `.materialize`, `.matchedGeometry`, or `.identity` for distinct visual effects. Custom SwiftUI transitions are also supported. ```swift import SwiftUI import UniversalGlass struct TransitionExamples: View { @State private var showCard = true var body: some View { VStack(spacing: 24) { if showCard { // Materialize transition - liquid morphing appearance Text("Materialize") .padding(24) .universalGlassEffect() .universalGlassEffectTransition(.materialize) // Matched geometry - shares movement with layout Text("Matched Geometry") .padding(24) .universalGlassEffect() .universalGlassEffectTransition(.matchedGeometry) // Identity - no morphing animation Text("Identity") .padding(24) .universalGlassEffect() .universalGlassEffectTransition(.identity) } // Custom SwiftUI transitions also work if showCard { Text("Custom Transition") .padding(24) .universalGlassEffect() .universalGlassTransition(.universalGlassMaterialBlur) } Button(showCard ? "Hide" : "Show") { withAnimation(.spring(duration: 0.45)) { showCard.toggle() } } .buttonStyle(.universalGlassProminent()) } } } ``` -------------------------------- ### Remove Fallback Tint from Glass Effect Source: https://github.com/aeastr/universalglass/blob/main/docs/Effects.md Demonstrates how to remove any fallback tint, ensuring only the material is used on older OS versions. ```swift // Remove fallback tint .universalGlassEffect(.thick.fallback(tint: nil)) ``` -------------------------------- ### Apply Glass Effect with Custom Tint Source: https://github.com/aeastr/universalglass/blob/main/README.md Apply a regular glass effect with a cyan tint. ```swift .universalGlassEffect(.regular.tint(.cyan)) ``` -------------------------------- ### Apply Default Shadow for Universal Glass Effect Source: https://github.com/aeastr/universalglass/wiki/UniversalGlassEffects Use the default shadow configuration for the regular glass effect in fallback mode. This is automatically applied if not specified otherwise. ```swift .universalGlassEffect(.regular.shadow(.default)) ``` -------------------------------- ### Apply Glass Effect with Custom Shadow Source: https://github.com/aeastr/universalglass/blob/main/README.md Apply a regular glass effect with a custom red shadow. ```swift .universalGlassEffect(.regular.shadow(UniversalGlassShadow(color: .red, radius: 12))) ``` -------------------------------- ### Apply Glass Effect with Interactivity Source: https://github.com/aeastr/universalglass/blob/main/README.md Apply a regular glass effect that is interactive. ```swift .universalGlassEffect(.regular.interactive()) ``` -------------------------------- ### Apply Basic Glass Effect Source: https://github.com/aeastr/universalglass/blob/main/README.md Apply a regular glass effect with a purple tint to a Text view. ```swift Text("Hello") .universalGlassEffect(.regular.tint(.purple)) ``` -------------------------------- ### Apply Glass Effect with Fallback Material Source: https://github.com/aeastr/universalglass/blob/main/README.md Apply a regular glass effect, specifying a fallback material. ```swift .universalGlassEffect(.regular.fallback(material: .thin)) ``` -------------------------------- ### Apply Glass Effect with Fallback Material and Tint Source: https://github.com/aeastr/universalglass/blob/main/README.md Apply a thick glass effect, specifying a fallback material and tint color. ```swift .universalGlassEffect(.thick.fallback(material: .regular, tint: .blue.opacity(0.2))) ``` -------------------------------- ### Backported Glass Effects in SwiftUI Source: https://context7.com/aeastr/universalglass/llms.txt Demonstrates using backported modifiers like `.glassEffect`, `.glassEffectUnion`, and `.glassEffectTransition` with native API names on older platforms. Requires importing UniversalGlassBackports. ```swift import SwiftUI import UniversalGlass import UniversalGlassBackports struct BackportExamples: View { @Namespace private var ns var body: some View { // GlassEffectContainer instead of UniversalGlassEffectContainer GlassEffectContainer { VStack(spacing: 24) { // .glassEffect instead of .universalGlassEffect Text("Backported Glass") .padding() .glassEffect(.regular.tint(.mint)) // .glassEffect with custom shape Circle() .frame(width: 80, height: 80) .glassEffect(in: Circle()) // .glassEffectUnion instead of .universalGlassEffectUnion HStack(spacing: 0) { Text("Left") .padding() .glassEffect() .glassEffectUnion(id: "merged", namespace: ns) Text("Right") .padding() .glassEffect() .glassEffectUnion(id: "merged", namespace: ns) } // .glass and .glassProminent button styles Button("Glass") {} .buttonStyle(.glass) .tint(.blue) Button("Prominent") {} .buttonStyle(.glassProminent) .tint(.purple) // .glassEffectTransition Text("With Transition") .padding() .glassEffect() .glassEffectTransition(.materialize) } } } } ``` -------------------------------- ### Applying UniversalGlass Styles with Modifiers Source: https://github.com/aeastr/universalglass/wiki/UniversalGlassButtonStyles Shows how to apply UniversalGlass button styles directly as view modifiers, mimicking SwiftUI syntax. ```swift .universalGlassButtonStyle() .universalGlassProminentButtonStyle() ``` -------------------------------- ### Override Fallback Material for Glass Effect Source: https://github.com/aeastr/universalglass/blob/main/docs/Effects.md Shows how to specify a custom fallback material for older OS versions when applying a glass effect. ```swift // Custom fallback material .universalGlassEffect(.regular.fallback(material: .thin)) ``` -------------------------------- ### Apply Universal Glass Prominent Button Style Source: https://github.com/aeastr/universalglass/blob/main/README.md Style a Button with the prominent universal glass style and a pink tint. ```swift Button("Join Beta") { } .buttonStyle(.universalGlassProminent()) .tint(.pink) ``` -------------------------------- ### UniversalGlass Configuration Presets Source: https://context7.com/aeastr/universalglass/llms.txt Utilize built-in presets that match Apple's material tiers for consistent glass effects across platforms. These presets automatically adapt to use native liquid glass on iOS 26+ or material fallbacks on older systems. ```swift import SwiftUI import UniversalGlass struct GlassConfigurationExamples: View { var body: some View { VStack(spacing: 20) { // Identity - No effect Text("Identity").padding() .universalGlassEffect(.identity) // Ultra thin - Clear liquid glass, ultra thin material fallback Text("Ultra Thin").padding() .universalGlassEffect(.ultraThin) // Thin - Clear glass with faint background tint Text("Thin").padding() .universalGlassEffect(.thin) // Regular - Standard glass effect (default) Text("Regular").padding() .universalGlassEffect(.regular) // Thick - Deeper background tint Text("Thick").padding() .universalGlassEffect(.thick) // Ultra thick - Heaviest tint for deeper plates Text("Ultra Thick").padding() .universalGlassEffect(.ultraThick) // Clear - Clear glass with ultra thin material fallback Text("Clear").padding() .universalGlassEffect(.clear) } } } ``` -------------------------------- ### Disable Shadow for Glass Effect Source: https://github.com/aeastr/universalglass/blob/main/docs/Effects.md Shows how to explicitly disable shadows for a glass effect. ```swift // No shadow .universalGlassEffect(.regular.shadow(.none)) ``` -------------------------------- ### Supporting APIs for Glass Effects Source: https://github.com/aeastr/universalglass/blob/main/docs/Containers.md These helper methods are used in conjunction with UniversalGlassEffectContainer. They store metadata for the fallback renderer or use SwiftUI's native implementation on newer OS versions. ```swift View.universalGlassEffectUnion(id:namespace:rendering:) ``` ```swift View.universalGlassEffectID(_:in:rendering:) ``` ```swift View.universalGlassEffectTransition(_:) ``` -------------------------------- ### Swift Package Manager Dependency Configuration Source: https://context7.com/aeastr/universalglass/llms.txt Configuration for adding UniversalGlass and UniversalGlassBackports as dependencies in your Swift Package Manager project. ```swift // Package.swift dependency configuration // dependencies: [ // .package(url: "https://github.com/Aeastr/UniversalGlass.git", branch: "main") // ] // // targets: [ // .target( // name: "YourApp", // dependencies: [ // .product(name: "UniversalGlass", package: "UniversalGlass"), // .product(name: "UniversalGlassBackports", package: "UniversalGlass"), // ] // ) // ] ``` -------------------------------- ### Add UniversalGlass Dependency Source: https://github.com/aeastr/universalglass/blob/main/README.md Add the UniversalGlass package to your project's dependencies. ```swift dependencies: [ .package(url: "https://github.com/Aeastr/UniversalGlass.git", branch: "main") ] ``` -------------------------------- ### Apply Custom Shadow to Universal Glass Effect Source: https://github.com/aeastr/universalglass/wiki/UniversalGlassEffects Apply a custom shadow to the glass effect in fallback mode. This allows for fine-grained control over depth and appearance. ```swift .universalGlassEffect( .regular.shadow(UniversalGlassShadow(color: .red, radius: 12)) ) ``` -------------------------------- ### UniversalGlass Grouping and Unions Source: https://github.com/aeastr/universalglass/blob/main/docs/Effects.md APIs for coordinating multiple views to create a unified glass effect. ```APIDOC ## Grouping and Union Modifiers for UniversalGlass Effects ### Description These modifiers help coordinate multiple views to create a unified glass effect, especially on platforms that support it. They stash metadata that the fallback container consumes to merge participants. ### Methods - `universalGlassEffectUnion(id:namespace:rendering:) - `universalGlassEffectID(_:in:rendering:) ### Parameters - `id` (Hashable) - A unique identifier for the union. - `namespace` (Namespace.ID) - The namespace for the union. - `rendering` (UniversalGlassRendering) - Specifies how the glass effect should be rendered. - `in` (Namespace) - The namespace for grouping. ### Request Example ```swift // Example usage within a view hierarchy View.universalGlassEffectUnion(id: "myUnion", namespace: namespace) View.universalGlassEffectID("myElement", in: namespace) ``` ### Response - Enables coordinated glass effects across multiple views. ``` -------------------------------- ### UniversalGlass Effects API Source: https://github.com/aeastr/universalglass/blob/main/docs/Effects.md This section covers the primary API surface for applying glass effects to SwiftUI Views. ```APIDOC ## View Modifiers for UniversalGlass Effects ### Description These modifiers apply glass effects to SwiftUI Views, with options for configuration and rendering. ### Methods - `universalGlassEffect(rendering:)` - `universalGlassEffect(_:rendering:)` - `universalGlassEffect(_:in:rendering:)` - `universalGlassEffect(in:rendering:)` ### Parameters - `rendering` (UniversalGlassRendering) - Specifies how the glass effect should be rendered (e.g., `.automatic`, `.glass`, `.material`). - `configuration` (UniversalGlassConfiguration) - Optional configuration for the glass effect, bundling fallback materials and glass options. - `namespace` (Namespace.ID) - Used for grouping and union effects. - `in` (Namespace) - The namespace for grouping and union effects. ### Request Example ```swift import SwiftUI import UniversalGlass struct ContentView: View { var body: some View { Text("Hello, UniversalGlass!") .universalGlassEffect(.regular.tint(.cyan)) } } ``` ### Response - The view will have the specified glass effect applied. ### Response Example (No specific response body, the effect is applied directly to the view.) ``` -------------------------------- ### Apply Universal Glass Effect Transition Source: https://github.com/aeastr/universalglass/wiki/UniversalGlassContainers Apply this modifier to a view to enable glass effect transitions. This is handled by SwiftUI's implementation on new OS builds and stored in the environment for the fallback. ```swift View.universalGlassEffectTransition(_:) ``` -------------------------------- ### Force Global Glass Rendering Mode Source: https://github.com/aeastr/universalglass/blob/main/README.md Force all UniversalGlass effects within a view hierarchy to use the material rendering mode. ```swift MyApp() .universalGlassRenderingMode(.material) // Force fallback ``` -------------------------------- ### Custom Transitions per Effect Source: https://github.com/aeastr/universalglass/wiki/UniversalGlassEffects Override the default transition for specific glass effects using `.universalGlassTransition()` with predefined or custom transition types. ```swift VStack { Text("Slide Transition") .universalGlassEffect() .universalGlassTransition(.slide) Text("Scale Transition") .universalGlassEffect() .universalGlassTransition(.scale) // Use built-in glass transitions Text("Blur Without Scale") .universalGlassEffect() .universalGlassTransition(.universalGlassMaterialBlurWithoutScale) } ``` -------------------------------- ### Universal Glass Button Styles Source: https://context7.com/aeastr/universalglass/llms.txt Apply glass button styles that mirror SwiftUI's `.glass` and `.glassProminent` APIs. These automatically fall back to bordered styles on older OS versions. Use `.universalGlass()` for standard and `.universalGlassProminent()` for prominent styles. ```swift import SwiftUI import UniversalGlass struct ButtonStyleExamples: View { var body: some View { VStack(spacing: 24) { // Standard glass button style Button("Glass Button") { print("Tapped!") } .buttonStyle(.universalGlass()) .tint(.blue) // Prominent glass button style (filled with tint color) Button("Prominent Glass") { print("Tapped!") } .buttonStyle(.universalGlassProminent()) .tint(.pink) // With control size modifier Button("Large Button") { print("Tapped!") } .buttonStyle(.universalGlassProminent()) .tint(.purple) .controlSize(.large) // Force material fallback (useful for testing) Button("Material Fallback") { print("Tapped!") } .buttonStyle(.universalGlass(rendering: .material)) // Using view modifier shorthand Button("Shorthand Style") { print("Tapped!") } .universalGlassButtonStyle() Button("Prominent Shorthand") { print("Tapped!") } .universalGlassProminentButtonStyle() } } } ``` -------------------------------- ### Apply Universal Glass Button Style Source: https://github.com/aeastr/universalglass/blob/main/docs/ButtonStyles.md Use the .universalGlassProminent() modifier to apply a prominent glass button style. Configure tint and control size as needed. This is useful for creating visually distinct call-to-action buttons. ```swift Button("Action") { } \ .buttonStyle(.universalGlassProminent()) \ .tint(.pink) \ .controlSize(.large) ``` -------------------------------- ### Chain Multiple Glass Effect Modifiers Source: https://github.com/aeastr/universalglass/blob/main/README.md Chain multiple glass effect configurations including fallback, shadow, tint, and interactivity. ```swift .universalGlassEffect( .ultraThick .fallback(material: .thin, tint: .cyan.opacity(0.3)) .shadow(UniversalGlassShadow(color: .blue, radius: 16)) .tint(.purple) .interactive() ) ``` -------------------------------- ### Effect Containers and Unions for Merged Glass Surfaces Source: https://context7.com/aeastr/universalglass/llms.txt Group multiple glass effects within a `UniversalGlassEffectContainer` to render as a fused surface. Use `.universalGlassEffectUnion(id: ..., namespace: ...)` to allow neighboring elements to merge into a single glass sheet. ```swift import SwiftUI import UniversalGlass struct ContainerExamples: View { @Namespace private var ns @State private var showDetails = true var body: some View { // Container optimizes rendering of multiple glass effects UniversalGlassEffectContainer { HStack(spacing: 0) { // Views with same union ID merge into one glass surface Image(systemName: "person.circle") .font(.largeTitle) .frame(width: 80, height: 80) .universalGlassEffect() .universalGlassEffectUnion(id: "profile", namespace: ns) if showDetails { VStack(alignment: .leading) { Text("John Doe") .font(.headline) Text("Developer") .font(.caption) } .padding() .universalGlassEffect() .universalGlassEffectUnion(id: "profile", namespace: ns) } } // Standalone glass effect (not merged) Text("Settings") .padding() .universalGlassEffect() } .onTapGesture { withAnimation(.spring(duration: 0.45)) { showDetails.toggle() } } } } ``` -------------------------------- ### Apply Glass Effect with Custom Shape Source: https://github.com/aeastr/universalglass/blob/main/README.md Apply a glass effect to a Circle shape, conforming to its bounds. ```swift Circle() .frame(width: 120, height: 120) .universalGlassEffect(in: Circle()) ``` -------------------------------- ### UniversalGlass API Overloads Source: https://github.com/aeastr/universalglass/blob/main/docs/Effects.md Lists the available overloads for the universalGlassEffect modifier in UniversalGlassEffect+View.swift. ```swift View.universalGlassEffect(rendering:) View.universalGlassEffect(_:rendering:) View.universalGlassEffect(_:in:rendering:) View.universalGlassEffect(in:rendering:) ``` -------------------------------- ### Apply UniversalGlass Effects to Views Source: https://context7.com/aeastr/universalglass/llms.txt Apply various glass effects to any SwiftUI view. Use `.universalGlassEffect()` with different configurations for tinting, custom shapes, and interactivity. On iOS 26+, native APIs are used; otherwise, a material-based fallback is rendered. ```swift import SwiftUI import UniversalGlass struct GlassEffectExamples: View { var body: some View { VStack(spacing: 24) { // Basic glass effect with default capsule shape Text("Hello Glass") .padding(.horizontal, 36) .padding(.vertical, 16) .universalGlassEffect() // Glass effect with tinting Text("Tinted Glass") .padding(.horizontal, 36) .padding(.vertical, 16) .universalGlassEffect(.regular.tint(.purple)) // Glass effect with custom shape Circle() .frame(width: 120, height: 120) .universalGlassEffect(in: Circle()) // Interactive glass that responds to touch Text("Interactive") .padding(.horizontal, 36) .padding(.vertical, 16) .universalGlassEffect(.regular.interactive()) // Fully customized glass effect with chained modifiers Text("Custom Glass") .padding(.horizontal, 36) .padding(.vertical, 16) .universalGlassEffect( .ultraThick .fallback(material: .thin, tint: .cyan.opacity(0.3)) .shadow(UniversalGlassShadow(color: .blue, radius: 16)) .tint(.purple) .interactive() ) } } } ``` -------------------------------- ### Add UniversalGlassBackports Package Dependency Source: https://github.com/aeastr/universalglass/wiki/Backports Include the UniversalGlassBackports product alongside the main UniversalGlass module in your Swift Package Manager dependencies. This allows your application to utilize the backported API surface. ```swift .package(url: "https://github.com/aether-patina/UniversalGlass", from: "1.0.0"), .target( name: "YourApp", dependencies: [ .product(name: "UniversalGlass", package: "UniversalGlass"), .product(name: "UniversalGlassBackports", package: "UniversalGlass"), ] ) ``` -------------------------------- ### Set Global Rendering Mode for Glass Effects Source: https://context7.com/aeastr/universalglass/llms.txt Apply `.universalGlassRenderingMode(.material)` to force all child glass effects to use the material fallback renderer. The default `.automatic` mode uses native rendering on iOS 26+ and falls back otherwise. ```swift import SwiftUI import UniversalGlass struct RenderingModeExamples: View { var body: some View { VStack(spacing: 40) { // Force material fallback for entire hierarchy VStack(spacing: 16) { Text("Material Mode") .font(.headline) Text("Always Material") .padding() .universalGlassEffect() Button("Material Button") {} .buttonStyle(.universalGlass()) } .universalGlassRenderingMode(.material) // Automatic mode (default) - native on iOS 26+ VStack(spacing: 16) { Text("Automatic Mode") .font(.headline) Text("Native when available") .padding() .universalGlassEffect() } // .universalGlassRenderingMode(.automatic) // default } } } ``` -------------------------------- ### UniversalGlass Configuration Modifiers Source: https://github.com/aeastr/universalglass/blob/main/docs/Effects.md Modifiers to customize the appearance and behavior of UniversalGlass effects. ```APIDOC ## Configuration Modifiers for UniversalGlass Effects ### Description These modifiers allow for fine-grained control over the glass effect's appearance, including tinting, interactivity, fallback materials, and shadows. ### Methods - `.tint(Color)` - `.interactive()` - `.fallback(material: UniversalMaterial?, tint: Color?) - `.shadow(UniversalGlassShadow) ### Parameters - `tint` (Color) - Sets the tint color for the glass effect. - `interactive` - Enables interactive behavior for the glass effect. - `fallback` - Overrides the default fallback material and tint for older OS versions. - `material` (UniversalMaterial?) - The fallback material to use. - `tint` (Color?) - The fallback tint color to use. - `shadow` - Configures the shadow applied to the glass effect. - `UniversalGlassShadow` - A struct defining shadow properties (color, radius, opacity). ### Built-in Configurations - `.identity`: No effect. - `.ultraThin`: Clear liquid glass over `.ultraThinMaterial`. - `.thin`: Clear glass tinted slightly toward the platform background. - `.regular`: Maps to `Glass.regular`. - `.thick`: Deeper background tint alongside `.thickMaterial`. - `.ultraThick`: Heavier tint to emulate Apple's deeper plates. - `.clear`: Clear glass with ultra thin material fallback. ### Shadow Presets - `.default`: Subtle black blur (8pt radius, 0.04 opacity). - `.none`: No shadow. ### Request Example ```swift // Custom tint .universalGlassEffect(.regular.tint(.cyan)) // Custom fallback material and tint .universalGlassEffect(.thick.fallback(material: .regular, tint: .blue.opacity(0.2))) // Custom shadow .universalGlassEffect( .regular.shadow(UniversalGlassShadow(color: .red, radius: 12)) ) // No shadow .universalGlassEffect(.regular.shadow(.none)) ``` ### Response - The glass effect is configured with the specified parameters. ``` -------------------------------- ### Remove Glass Effect Shadow Source: https://github.com/aeastr/universalglass/blob/main/README.md Apply a regular glass effect and explicitly remove any shadow. ```swift .universalGlassEffect(.regular.shadow(.none)) ``` -------------------------------- ### Remove Fallback Tint for Universal Glass Effect Source: https://github.com/aeastr/universalglass/wiki/UniversalGlassEffects Disable the fallback tint color for the thick glass effect on older OS versions. This can be useful for specific design requirements. ```swift .universalGlassEffect(.thick.fallback(tint: nil)) ``` -------------------------------- ### Global Rendering Mode Override Source: https://github.com/aeastr/universalglass/wiki/UniversalGlassEffects Force all glass effects in a view hierarchy to use a specific rendering mode. Useful for testing fallback behavior, debugging, or A/B testing. ```swift MyApp() .universalGlassRenderingMode(.material) ``` ```swift MyApp() .universalGlassRenderingMode(.glass) ``` ```swift MyApp() .universalGlassRenderingMode(.automatic) ``` -------------------------------- ### Assign Universal Glass Effect ID Source: https://github.com/aeastr/universalglass/wiki/UniversalGlassContainers Assign a unique ID and namespace to a view for glass effect grouping. This metadata is consumed by the fallback renderer. ```swift View.universalGlassEffectID(_:in:rendering:) ``` -------------------------------- ### Apply Universal Glass Effect Union Source: https://github.com/aeastr/universalglass/wiki/UniversalGlassContainers Apply this modifier to a view to define its glass effect union properties, including ID, namespace, and rendering mode. This is used by the fallback renderer. ```swift View.universalGlassEffectUnion(id:namespace:rendering:) ``` -------------------------------- ### UniversalGlass Rendering Mode Environment Modifier Source: https://github.com/aeastr/universalglass/blob/main/docs/Effects.md Environment modifier to force a specific rendering mode for all glass effects within a view hierarchy. ```APIDOC ## Environment Modifier for UniversalGlass Rendering Mode ### Description This environment modifier allows you to force all glass effects within a view hierarchy to use a specific rendering mode. This is particularly useful for testing purposes. ### Method - `.universalGlassRenderingMode(_:)` ### Parameters - `mode` (UniversalGlassRenderingMode) - The rendering mode to force. Options include `.material` (force fallback) and `.glass` (force native glass effect when available). ### Request Example ```swift // Force material fallback rendering for all effects in MyApp MyApp() .universalGlassRenderingMode(.material) // Force glass rendering when available for all effects in MyApp MyApp() .universalGlassRenderingMode(.glass) ``` ### Response - All subsequent UniversalGlass effects within the hierarchy will adhere to the specified rendering mode. ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.