How to make a rectangular button rounded in iOS?

Juvin's photo
·Oct 27, 2020·

1 min read

As a beginner who starts learning iOS Development, you may find simple things like making a button rounded to be hard. It is actually easy to do it.

To make your rectangular button rounded, you must set the cornerRadius of the button to half of its height.

For example: -

buttonName.layer.cornerRadius = buttonName.frame.height / 2.0

Before setting cornerRadius


After setting cornerRadius


Note: If your button is square, i.e. having same width and height. Then, using the above code will not work. Instead, it will be displayed as a circle. To overcome this issue, please set a constant value (For eg: 10.0) for the button’s cornerRadius. The value should be changed proportionately to the size of the button.

Share this