How to round specific corners of a UIView using maskedCorners

You can set the corner radius of a UIView and its subclasses by using the following code

But what if you want to only add rounded corners to specific corners. This is where the maskedCorners property comes into play. It’s an array so you’ll need to add the corners you don’t want rounding off. Here is an example for you to use.

Since Xcode 6, we have been given the ability to see the changes live within Storyboard / Interface editor.

The following class allows you to do just that!

Don’t forget to change the subclass of the UIView!


And finally, pop over to attribute inspector and you’ll be able to see and make the changes!