Skip to content

Instantly share code, notes, and snippets.

@aheze
Created May 9, 2023 23:22
Show Gist options
  • Save aheze/c616d1bf8a07daba03ef4ee6f8e8b92b to your computer and use it in GitHub Desktop.
Save aheze/c616d1bf8a07daba03ef4ee6f8e8b92b to your computer and use it in GitHub Desktop.
/// Use UIKit blurs in SwiftUI.
struct VisualEffectView: UIViewRepresentable {
/// The blur's style.
public var style: UIBlurEffect.Style
/// Use UIKit blurs in SwiftUI.
public init(_ style: UIBlurEffect.Style) {
self.style = style
}
public func makeUIView(context: Context) -> UIVisualEffectView {
UIVisualEffectView()
}
public func updateUIView(_ uiView: UIVisualEffectView, context: Context) {
uiView.effect = UIBlurEffect(style: style)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment