How to Easily Add Shadow and Corner Radius to UIView in Swift Using Extensions

Ozan Çiçek
Jul 15, 2024

SS From device

Hello Everyone, in this article, I will show you how to add both corner radius and shadow to a UIView simultaneously in Swift. You can achieve this easily with a single UIView extension function.

You can customize individual properties as needed, such as applying corner radius to specific corners only.

Alternatively, you can change all properties at once.

The function creates a new UIView named containerView and applies the necessary shadow and corner rounding properties to this view. Then, it adds the current UIView content (self) into this containerView and defines the necessary constraints.

I hope this article was helpful. If you have any questions or suggestions, please feel free to leave a comment.

Goodbye!
Contact: info@ozancicek.dev

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

Ozan Çiçek
Ozan Çiçek

Written by Ozan Çiçek

iOS Developer, Student #swift #uikit #apple #iOS #swiftui

No responses yet