Created
February 20, 2020 15:51
-
-
Save Lavmint/2491a6bd52e75e7d1da97f47c1160c48 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
import Foundation | |
import SwiftUI | |
struct FocusView: View { | |
let path: Path | |
let backgroundColor: Color | |
init(path: Path, backgroundColor: Color = Color.black.opacity(0.3)) { | |
self.path = path | |
self.backgroundColor = backgroundColor | |
} | |
var body: some View { | |
GeometryReader { (geo: GeometryProxy) in | |
self.dimmer(with: geo) | |
} | |
.edgesIgnoringSafeArea(.all) | |
} | |
private func dimmer(with geo: GeometryProxy) -> some View { | |
Rectangle() | |
.fill(backgroundColor) | |
.mask( | |
Path { (path) in | |
path.addPath( | |
Rectangle() | |
.path(in: geo.frame(in: .local)) | |
) | |
path.addPath( | |
self.path | |
) | |
} | |
.fill(style: FillStyle(eoFill: true)) | |
) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment