Skip to content

Instantly share code, notes, and snippets.

@jacobsapps
Created June 24, 2026 10:13
Show Gist options
  • Select an option

  • Save jacobsapps/5c70dc0d382d06ab2d86b32cebce1475 to your computer and use it in GitHub Desktop.

Select an option

Save jacobsapps/5c70dc0d382d06ab2d86b32cebce1475 to your computer and use it in GitHub Desktop.
ProgressiveBlurView from My top 3 design “Kisses” I like to add to every app
private final class VariableBlurUIView: UIVisualEffectView {
override func layoutSubviews() {
super.layoutSubviews()
let filter = (NSClassFromString("CAFilter") as! NSObject.Type)
.perform(NSSelectorFromString("filterWithType:"), with: "variableBlur")!
.takeUnretainedValue() as! NSObject
filter.setValue(20, forKey: "inputRadius")
filter.setValue(makeMaskImage(), forKey: "inputMaskImage")
filter.setValue(true, forKey: "inputNormalizeEdges")
subviews.first?.layer.filters = [filter]
}
private func makeMaskImage() -> CGImage {
let gradient = CIFilter.linearGradient()
gradient.color0 = CIColor.white
gradient.color1 = CIColor.clear
gradient.point0 = CGPoint(x: 0, y: bounds.height)
gradient.point1 = CGPoint(x: 0, y: 0)
return CIContext().createCGImage(
gradient.outputImage!,
from: CGRect(origin: .zero, size: bounds.size)
)!
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment