I am trying to give shadow to my VStack (only at top) but when I do like below shadow is visible to all sides like button, Text. But I am trying to give border to only container.
.background(Color.white // any non-transparent background
.shadow(color: Color.red, radius: 10, x: 0, y: 0)
)
I want UI like below
Thank you for help
Try using the mask(_:)
modifier, as shown in this answer.
.background(
Color.white // any non-transparent background
.shadow(color: Color.red, radius: 10, x: 0, y: 0)
.mask(Rectangle().padding(.top, -20)) /// here!
)
Result:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With