Skip to content

Instantly share code, notes, and snippets.

@peantunes
Last active May 11, 2021 20:57
Show Gist options
  • Save peantunes/117ca4b54e9718286be5d094f6cd7de3 to your computer and use it in GitHub Desktop.
Save peantunes/117ca4b54e9718286be5d094f6cd7de3 to your computer and use it in GitHub Desktop.
private struct GroundReflectionViewModifier: ViewModifier {
let offsetY: CGFloat
func body(content: Content) -> some View {
content // base content
.background( // using background to duplicate the content with the View
content // using the same content here to duplicate
// this will create a flip in the axis Y with the anchor in the bottom
.scaleEffect(x: 1.0, y: -1.0, anchor: .bottom)
// adding the opacity
.opacity(0.3)
// and receiving the offsetY as parameter
.offset(y: offsetY)
)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment