Skip to content

Instantly share code, notes, and snippets.

@Lavmint
Created February 20, 2020 15:51
Show Gist options
  • Save Lavmint/2491a6bd52e75e7d1da97f47c1160c48 to your computer and use it in GitHub Desktop.
Save Lavmint/2491a6bd52e75e7d1da97f47c1160c48 to your computer and use it in GitHub Desktop.
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