Created
August 14, 2022 17:56
-
-
Save tixster/ac792671e614c8c58c19884a8b36b0f8 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
| import SwiftUI | |
| public class UIBackdropView: UIView { | |
| override class public var layerClass: AnyClass { | |
| return NSClassFromString("CABackdropLayer") ?? CALayer.self | |
| } | |
| } | |
| public struct Backdrop: UIViewRepresentable { | |
| public func makeUIView(context: Context) -> UIBackdropView { | |
| UIBackdropView() | |
| } | |
| public func updateUIView(_ uiView: UIBackdropView, context: Context) { } | |
| } | |
| public struct Blur: View { | |
| public var radius: CGFloat = 3 | |
| public var opaque: Bool = false | |
| public var body: some View { | |
| Backdrop() | |
| .blur(radius: radius, opaque: opaque) | |
| } | |
| } | |
| public extension View { | |
| func backgroudBlur(radius: CGFloat = 3, opaque: Bool = false) -> some View { | |
| self | |
| .background(Blur(radius: radius, opaque: opaque)) | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment