Real‑time frosted glass and liquid‑like refraction for any SwiftUI view – no screenshots, no boilerplate.
| 🔍 Zero screenshots | Background is captured automatically – just drop liquidGlassBackground on any view. |
| ⚡ Real‑time | Optimised MTLTexture snapshots + lazy redraw; redraws only when the background actually changes. |
| 🛠 Flexible update modes | .continuous, .once, .manual via the updateMode modifier. |
| 🧩 Pure SwiftUI | Works seamlessly in both worlds. |
| 💤 Battery‑friendly | MTKView stays paused until the provider notifies it – no wasted frames. |
Add LiquidGlass through Swift Package Manager:
https://github.com/BarredEwe/LiquidGlass.git
Or via Xcode » Package Dependencies… Select LiquidGlass and you’re done.
Button("Glass Text") { }
.liquidGlassBackground(cornerRadius: 60)| Mode | What it does | Best for |
|---|---|---|
.continuous(interval:) |
Captures every n seconds. | Animating backgrounds, parallax, fancy UIs. |
.once |
Captures exactly one frame. | Static dialogs, settings sheets. |
.manual |
Capture only when you call invalidate() |
Power‑saving, custom triggers. |
Via SwiftUI:
.liquidGlassBackground(updateMode: .once)- Fragment shader – tweak
Sources/LiquidGlass/Shaders/LiquidGlassShader.metalto adjust blur radius, refraction strength, tint or chromatic aberration. Two editable functions:sampleBackground()– distort UVs / add ripplepostProcess()– lift saturation, add tint, vignette, bloom.
- Performance knobs – lower snapshot interval, switch to
.once, or optimise shader loops.
- Snapshot covers only the area behind the glass – minimal memory.
- Layers above the glass are never hidden → no flicker.
- Lazy redraw means nearly zero GPU when nothing changes.
The glass doesn’t update when I scroll.
Use.continuous(interval: 0.016)(≈60 fps) or trigger.manual’sinvalidate()inscrollViewDidScroll.
MIT © 2025 • BarredEwe / Prefire
Made with ❤️ & Metal

