How to round the corners of a UIView

UIViews and its subclasses have the ability to round their corners thanks to the underlying CALayer. In one line of code you are able to add rounded edges to any UIView, UILabel, UIButton and so on and so forth.

The following snippet shows how to add a rounded corner of 10 radius

With this in mind, you can also make a square into a circle by applying the corner radius at a value half the width or height of the view. Just like so:-

Since Xcode 6 we’ve been given the ability to create custom classes that can be edited in the interface builder (aka storyboard)


The following example generates a UIView with an editable border width, color, and corner radius:-

Don’t forget to change the UIView to the new custom class we just made!


And finally pop over to the attribute inspector and you’ll see the newfound properties