Created
May 9, 2023 23:22
-
-
Save aheze/c616d1bf8a07daba03ef4ee6f8e8b92b to your computer and use it in GitHub Desktop.
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
/// 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