Skip to content

Instantly share code, notes, and snippets.

@thepearl
Last active December 15, 2022 17:13
Show Gist options
  • Save thepearl/95695c8e2f2f850c459570d58683deac to your computer and use it in GitHub Desktop.
Save thepearl/95695c8e2f2f850c459570d58683deac to your computer and use it in GitHub Desktop.
struct ShadowBorderModifier: ViewModifier {
func body(content: Content) -> some View {
content
.border(Color.black, width: 1)
.shadow(radius: 5)
}
}
extension View {
func dropShadow() -> some View {
ModifiedContent(content: self, modifier: ShadowBorderModifier())
}
}
// Call the modifier on any View
Text("Hello, world!")
.dropShadow()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment