Shadow could definitely bring your design to a next level. Be sure to include them in your design.
Adds a shadow to the view.
Apple Documentation
In this tutorial, you’ll learn what is Shadow in SwiftUI. You’ll learn:
- How to use Shadow.
Prerequisites
To follow along this tutorial, you’ll need some basic knowledge in:
- A basic familiarity with Swift.
- At least Xcode 11
Shadow
Including shadow and corner radius is a big mess in UIKit where you’ll need to create two view to achieve that. Below is just an example of including both corner radius and shadow.
1 2 3 4 5 |
Rectangle() .fill(Color.green) .cornerRadius(4.0) .shadow(radius: 4.0) .frame(width: 200, height: 200) |

You could even adjust the radius of the shadow.
1 |
.shadow(radius: 20.0) |

If the shadow color doesn’t suit your design. Then you can even opt to pick your own color.
1 |
.shadow(color: Color.blue, radius: 20, x: 0, y: 0) |

You can even move the shadow around by playing around with the x and y axis.
1 |
.shadow(color: Color.blue, radius: 20, x: 50, y: 50) |

Where to go From Here
If you feel like you are ready to take on more challenges, feel free to check out some other tutorials that we have created:
Be First to Comment