Swift MIT

VariableBlur

SwiftUI variable blur (progressive blur)

N

nikstar

Dernière activité 2 janv. 2026
nikstar/VariableBlur

698

étoiles

24

forks

0

issues ouvertes

progressive-blurswiftswiftuivariable-blur

Ce README est souvent en anglais.

VariableBlur

VariableBlur

SwiftUI variable blur (progressive blur)

First of all, all hard work was done by jtrivedi - I just made some minor adjustments.

Changes in this version:

  • all code is in one file
  • dynamically generates gradient image allowing for further adjustments
  • fixes crash when switching between light and dark mode
  • supports upside down variable blurs (clear at the top, blurred at the bottom)

Use of private API is obfuscated and did not trigger App Store rejection for me.

Install

Copy VariableBlur.swift to your project.

SPM

To add a package dependency to your Xcode project, select File > Add Package and enter this repository's URL (https://github.com/nikstar/VariableBlur).

Example

Used to create image on top of this page:

ZStack(alignment: .top) {
    Color.white
    Color.blue.opacity(0.3)
    Image("im")
        .resizable()
        .aspectRatio(contentMode: .fit)
        .padding(.horizontal, 50)
    Text("VariableBlur")
        .font(.largeTitle.monospaced().weight(.bold))
        .padding(.top, 230)
        .foregroundStyle(.white.opacity(0.9))
}
.overlay(alignment: .top) {
    VariableBlurView(maxBlurRadius: 20, direction: .blurredTopClearBottom)
        .frame(height: 200)
}
.ignoresSafeArea()

Blur matching status bar/cutout safe area:

ContentView()
    .overlay(alignment: .top) {
        GeometryReader { geom in
            VariableBlurView(maxBlurRadius: 10)
                .frame(height: geom.safeAreaInsets.top)
                .ignoresSafeArea()
        }
    }

New: BackgroundBlur

Add background blur without any additional effects. See BackgroundBlur.swift.

HStack(spacing: 0) {
    Color.blue
    Color.blue.opacity(0.2)
}
.overlay {
    BackgroundBlur(radius: 20)
        .frame(width: 200, height: 100)
        .clipShape(.capsule)
}
.ignoresSafeArea()

Projets similaires

Variable blur effects for SwiftUI, powered by Metal

Swiftblur-rampmetal-shaderprogressive-blur
Ddaprice
307 étoiles4

Dynamic blur background view with tint color (UIVisualEffectView subclass) 📱

Swiftappleblureffects
Eefremidze
1,4 k étoiles91

A library for progressive blurs in SwiftUI.

Swift
Jjoogps
2,1 k étoiles45