Created
October 19, 2022 18:29
-
-
Save aheze/2b53265eca22e6aae332132632e94505 to your computer and use it in GitHub Desktop.
This file contains 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) | |
} | |
} | |
/// usage: | |
VisualEffectView(.systemUltraThinMaterialDark) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment