High-performance blur effect for UIKit, similar to SwiftUI’s blur modifier.
Instantiate BlurView and add any views you want to blur as its subviews.
Adjust its blurRadius property to control the level of blur.
import BlurView
let blurView = BlurView()
blurView.blurRadius = 20
blurView.addSubview(mySubview)This view supports animating the blur radius using UIKit’s animation APIs:
UIView.animate(withDuration: 0.3) {
blurView.blurRadius = 10
}.dependencies: [
.package(url: "https://github.com/juliensagot/uikit-blur-view", .upToNextMajor(from: "1.0.0"))
]
.targets: [
.target(
name: "Foo",
dependencies: [
.product(name: "BlurView", package: "uikit-blur-view")
]
)
]Please take a look at the DemoApp.
- It doesn’t work with
UIViewPropertyAnimator, and I have no idea how to make it work with it. (PRs are welcome!)
- A better implementation, compatible with
UIViewPropertyAnimator, is now available: https://github.com/lunacookies/BlurEffect
The Gaussian blur effect is produced via a call to a private API.
Although it has been obfuscated, using this package might result in your app being rejected by Apple, although this is very unlikely.
I shall not be held responsible if such an event occurs.
