Created
June 24, 2026 10:13
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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